     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug code and commands (P, T, G) to run debuggee code
     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 "run.asm"
    18                                  %ifidni __OUTPUT_FORMAT__, obj
    19                                   %include "debug.mac"
     1                              <1> [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   208          ------------------  <2>  note: usesection lDEBUG_CODE2
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   216          ------------------  <2>  note: usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   573                              <3> 
   574                              <3>  extern msg.copybpb
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????????            <1> lsCopyBPB:	resd 1	; if not all-zeroes, copy BPB to far pointer
   815 00000018 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   816 0000001A ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   817 0000001C ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   818                              <1> 	endstruc
   819                              <1> 
   820                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   821                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   822                              <1> %endif
   823                              <1> 
   824                              <1> 
   825                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   826                              <1> 
   827                              <1> 
   828                              <1> 	struc INPUTFILEHANDLE
   829 00000000 ????                <1> ifhHandle:	resw 1
   830 00000002 ????                <1> ifhFlags:	resw 1
   831 00000004 ????????            <1> ifhParentSeek:	resd 1
   832                              <1> 	endstruc
   833                              <1> 
   834                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   835                              <1> 	; same value as LBA flag for boot load input files
   836                              <1> ifhfTestReserved1:	equ 1000h
   837                              <1> ifhfTestReserved2:	equ 2000h
   838                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   839                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   840                              <1> 	; these four are valid for both input file handles and
   841                              <1> 	;  boot load input files.
   842                              <1> 
   843                              <1> 
   844                              <1> 	struc AREASTRUC
   845 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   846 00000018 ????????            <1> areastrucNext:		resd 1
   847 0000001C ????????            <1> areastrucPrev:		resd 1
   848 00000020 ????                <1> areastrucSubAmount:	resw 1
   849 00000022 ????                <1> areastrucSubOffset:	resw 1
   850 00000024 ????                <1> areastrucFunAmount:	resw 1
   851 00000026 ????                <1> areastrucFunOffset:	resw 1
   852                              <1> 	endstruc
   853                              <1> 
   854                              <1> 	struc AREASTRUCSUB
   855 00000000 ????????            <1> areastrucsubLinear:	resd 1
   856 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   857 00000008 ????                <1> areastrucsubListOffset:	resw 1
   858 0000000A ????                <1> areastrucsubListAmount:	resw 1
   859                              <1> 	endstruc
   860                              <1> 
   861                              <1> 	struc AREASTRUCFUN
   862 00000000 ????????            <1> areastrucfunLinear:	resd 1
   863 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   864 00000008 ????                <1> areastrucfunListOffset:	resw 1
   865 0000000A ????                <1> areastrucfunListAmount:	resw 1
   866                              <1> 	endstruc
   867                              <1> 
   868                              <1> 	struc AREA
   869 00000000 ????                <1> areastart:		resw 1
   870 00000002 ????                <1> areaend:		resw 1
   871 00000004 ????                <1> areamessage:		resw 1
   872 00000006 ????                <1> 			resw 1
   873                              <1> 	endstruc
   874                              <1> 
   875                              <1> 
   876                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   877                              <1> 
   878                              <1> 
   879                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   880                              <1> 
   881                              <1> 
   882                              <1> %if _VDD
   883                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   884                              <1> %macro RegisterModule 0.nolist
   885                              <1> 	db 0C4h, 0C4h, 58h, 0
   886                              <1> 	nop
   887                              <1> %endmacro
   888                              <1> %macro UnRegisterModule 0.nolist
   889                              <1> 	db 0C4h, 0C4h, 58h, 1
   890                              <1> 	nop
   891                              <1> %endmacro
   892                              <1> %macro DispatchCall 0.nolist
   893                              <1> 	db 0C4h, 0C4h, 58h, 2
   894                              <1> 	nop
   895                              <1> %endmacro
   896                              <1> %endif
   897                              <1> 
   898                              <1> %assign CODE_INSURE_COUNT 0
   899                              <1> 
   900                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   901                              <1> 		;  detects mistaken debugger breakpoints in its
   902                              <1> 		;  in-code-parameter by checking for a low-byte
   903                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   904                              <1> 		; Therefore, we insure that all destinations jumped to
   905                              <1> 		;  via that dispatcher do not happen to be located
   906                              <1> 		;  on an offset that gives 0CCh in the low byte.
   907                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   908                              <1> %ifn _LINK
   909                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   910                              <1> 	nop
   911                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   912                              <1>  %endif
   913                              <1> %endif
   914                              <1> 	%endmacro
   915                              <1> 
   916                              <1> 
   917                              <1> 		; dual code segments
   918                              <1> %if _DUALCODE && _PM
   919                              <1> 
   920                              <1> %if _DEBUG
   921                              <1> %idefine dualfunction comment
   922                              <1> %else
   923                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   924                              <1> %endif
   925                              <1> 
   926                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   927                              <1> %idefine dualdistance far
   928                              <1> 	%imacro dualcall 1.nolist
   929                              <1> %ifndef SECTION_OF_%1
   930                              <1>  %error Unknown target section for symbol %1
   931                              <1> %endif
   932                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   933                              <1>  %if _DEBUG
   934                              <1> 	jmp strict short %%skipdata
   935                              <1>  %endif
   936                              <1> 	dw %1
   937                              <1> %%skipdata:
   938                              <1> 	%endmacro
   939                              <1> 	%imacro nearcall 1.nolist
   940                              <1> %ifndef SECTION_OF_%1
   941                              <1>  %error Unknown target section for symbol %1
   942                              <1> %endif
   943                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   944                              <1> 	call %1
   945                              <1> %else
   946                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   947                              <1>  %if _DEBUG
   948                              <1> 	jmp strict short %%skipdata
   949                              <1>  %endif
   950                              <1> 	dw %1
   951                              <1> %%skipdata:
   952                              <1> %endif
   953                              <1> 	%endmacro
   954                              <1> 
   955                              <1> %elif _DUALCODE && ! _PM
   956                              <1> 
   957                              <1> %idefine dualfunction comment
   958                              <1> %idefine dualreturn
   959                              <1> %idefine dualdistance far
   960                              <1> 
   961                              <1> %ifn _LINK
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   963                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   964                              <1> 	%imacro dualcall 1.nolist
   965                              <1> %ifndef SECTION_OF_%1
   966                              <1>  %error Unknown target section for symbol %1
   967                              <1> %endif
   968                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   969                              <1> 	push cs
   970                              <1> 	call %1
   971                              <1> %else
   972                              <1> 	call relocatedzero:%1
   973                              <1> %push
   974                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   975                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   976                              <1> %pop
   977                              <1> %endif
   978                              <1> 	%endmacro
   979                              <1> 	%imacro relocatelist 2.nolist
   980                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   981                              <1> 	%endmacro
   982                              <1> %else		; _LINK
   983                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   984                              <1> 	%imacro dualcall_with_filename 2.nolist
   985                              <1> %ifndef SECTION_OF_%2
   986                              <1>  %error Unknown target section for symbol %2
   987                              <1> %endif
   988                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   989                              <1> 	push cs
   990                              <1> 	call %2
   991                              <1> %else
   992                              <1> 	call relocatedzero:%2
   993                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   994                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   995                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   996                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   997                              <1> %else
   998                              <1>  %error Wrong section
   999                              <1> %endif
  1000                              <1> %endif
  1001                              <1> 	%endmacro
  1002                              <1> %endif		; _LINK
  1003                              <1>  %if _DUALCODENEARDUAL
  1004                              <1> 
  1005                              <1> %if _LINK
  1006                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1007                              <1> 	%imacro nearcall_with_filename 2
  1008                              <1> %ifndef SECTION_OF_%2
  1009                              <1>  %error Unknown target section for symbol %2
  1010                              <1> %endif
  1011                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1012                              <1> 	call %2
  1013                              <1> %else
  1014                              <1>  %push
  1015                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1016                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1017                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1018                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1019                              <1> 	hiddenusesection %$targetsection
  1020                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1022                              <1> dualfunction
  1023                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1024                              <1> 	call %2
  1025                              <1> 	dualreturn
  1026                              <1> 	retf
  1027                              <1> 
  1028                              <1> 	hiddenusesection %$originalsection
  1029                              <1>   %endif
  1030                              <1>  %pop
  1031                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1032                              <1> %endif
  1033                              <1> 	%endmacro
  1034                              <1> %elif _LINK_COMPAT	; _LINK
  1035                              <1> 	%imacro nearcall 1
  1036                              <1> %ifndef SECTION_OF_%1
  1037                              <1>  %error Unknown target section for symbol %1
  1038                              <1> %endif
  1039                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1040                              <1> 	call %1
  1041                              <1> %else
  1042                              <1>  %push
  1043                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1044                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1045                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1046                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1047                              <1> 	hiddenusesection %$targetsection
  1048                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1050                              <1> dualfunction
  1051                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1052                              <1> 	call %1
  1053                              <1> 	dualreturn
  1054                              <1> 	retf
  1055                              <1> 
  1056                              <1> 	hiddenusesection %$originalsection
  1057                              <1>   %endif
  1058                              <1>  %pop
  1059                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1060                              <1> %endif
  1061                              <1> 	%endmacro
  1062                              <1> %else		; _LINK, _LINK_COMPAT
  1063                              <1> 	%imacro nearcall 1
  1064                              <1> %ifndef SECTION_OF_%1
  1065                              <1>  %error Unknown target section for symbol %1
  1066                              <1> %endif
  1067                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1068                              <1> 	call %1
  1069                              <1> %else
  1070                              <1>  %push
  1071                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1072                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1073                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1074                              <1> 	hiddenusesection %$targetsection
  1075                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1076                              <1> section_of %%nearcall_thunk_to_%1
  1077                              <1> dualfunction
  1078                              <1> %%nearcall_thunk_to_%1:
  1079                              <1> 	call %1
  1080                              <1> 	dualreturn
  1081                              <1> 	retf
  1082                              <1> 
  1083                              <1> 	hiddenusesection %$originalsection
  1084                              <1>   %endif
  1085                              <1>  %pop
  1086                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1087                              <1> %endif
  1088                              <1> 	%endmacro
  1089                              <1> %endif		; _LINK, _LINK_COMPAT
  1090                              <1>  %else
  1091                              <1> 	%imacro nearcall 1.nolist
  1092                              <1> %ifndef SECTION_OF_%1
  1093                              <1>  %error Unknown target section for symbol %1
  1094                              <1> %endif
  1095                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1096                              <1> 	call %1
  1097                              <1> %else
  1098                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1099                              <1>  %if _DEBUG
  1100                              <1> 	jmp strict short %%skipdata
  1101                              <1>  %endif
  1102                              <1> 	dw %1
  1103                              <1> %%skipdata:
  1104                              <1> %endif
  1105                              <1> 	%endmacro
  1106                              <1>  %endif
  1107                              <1> %elif ! _DUALCODE
  1108                              <1> 
  1109                              <1> %idefine dualfunction comment
  1110                              <1> %idefine dualreturn
  1111                              <1> %idefine dualdistance near
  1112                              <1> 	%imacro dualcall 1.nolist
  1113                              <1> 	call %1
  1114                              <1> 	%endmacro
  1115                              <1> 	%imacro nearcall 1.nolist
  1116                              <1> 	call %1
  1117                              <1> 	%endmacro
  1118                              <1> %assign _SYMBOLICDUALCODE 0
  1119                              <1> %assign _SYMBOLASMDUALCODE 0
  1120                              <1> 
  1121                              <1> %else
  1122                              <1>  %error Unexpected defines
  1123                              <1> %endif
  1124                              <1> 
  1125                              <1> %ifn _SYMBOLICDUALCODE
  1126                              <1>  %assign _SYMBOLASMDUALCODE 0
  1127                              <1> %endif
  1128                              <1> 
  1129                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1130                              <1> %idefine dual2function	dualfunction
  1131                              <1> %idefine dual2return	dualreturn
  1132                              <1> %idefine dual2distance	dualdistance
  1133                              <1> %idefine dual2call	dualcall
  1134                              <1>  %else
  1135                              <1> %idefine dual2function comment
  1136                              <1> %idefine dual2return
  1137                              <1> %idefine dual2distance near
  1138                              <1> 	%imacro dual2call 1.nolist
  1139                              <1> 	call %1
  1140                              <1> 	%endmacro
  1141                              <1>  %endif
  1142                              <1> 
  1143                              <1> 
  1144                              <1> 	numdef CHECKSECTION, 0
  1145                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1147                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1148                              <1> 
  1149                              <1> %if _CHECKCALLSECTION
  1150                              <1> 	%imacro call 1.nolist
  1151                              <1> 	%? %1
  1152                              <1> checksection %1, %?, call
  1153                              <1> 	%endmacro
  1154                              <1> %endif
  1155                              <1> %if _CHECKJMPSECTION
  1156                              <1> 	%imacro jmp 1.nolist
  1157                              <1> 	%? %1
  1158                              <1> checksection %1, %?, jmp
  1159                              <1> 	%endmacro
  1160                              <1> %endif
  1161                              <1> %if _CHECKJCCSECTION
  1162                              <1> 	%imacro je 1.nolist
  1163                              <1> 	%? %1
  1164                              <1> checksection %1, %?, jcc
  1165                              <1> 	%endmacro
  1166                              <1> 	%imacro jne 1.nolist
  1167                              <1> 	%? %1
  1168                              <1> checksection %1, %?, jcc
  1169                              <1> 	%endmacro
  1170                              <1> 	%imacro jz 1.nolist
  1171                              <1> 	%? %1
  1172                              <1> checksection %1, %?, jcc
  1173                              <1> 	%endmacro
  1174                              <1> 	%imacro jnz 1.nolist
  1175                              <1> 	%? %1
  1176                              <1> checksection %1, %?, jcc
  1177                              <1> 	%endmacro
  1178                              <1> 
  1179                              <1> 	%imacro jb 1.nolist
  1180                              <1> 	%? %1
  1181                              <1> checksection %1, %?, jcc
  1182                              <1> 	%endmacro
  1183                              <1> 	%imacro jnb 1.nolist
  1184                              <1> 	%? %1
  1185                              <1> checksection %1, %?, jcc
  1186                              <1> 	%endmacro
  1187                              <1> 	%imacro jbe 1.nolist
  1188                              <1> 	%? %1
  1189                              <1> checksection %1, %?, jcc
  1190                              <1> 	%endmacro
  1191                              <1> 	%imacro jnbe 1.nolist
  1192                              <1> 	%? %1
  1193                              <1> checksection %1, %?, jcc
  1194                              <1> 	%endmacro
  1195                              <1> 	%imacro jc 1.nolist
  1196                              <1> 	%? %1
  1197                              <1> checksection %1, %?, jcc
  1198                              <1> 	%endmacro
  1199                              <1> 	%imacro jnc 1.nolist
  1200                              <1> 	%? %1
  1201                              <1> checksection %1, %?, jcc
  1202                              <1> 	%endmacro
  1203                              <1> 	%imacro ja 1.nolist
  1204                              <1> 	%? %1
  1205                              <1> checksection %1, %?, jcc
  1206                              <1> 	%endmacro
  1207                              <1> 	%imacro jna 1.nolist
  1208                              <1> 	%? %1
  1209                              <1> checksection %1, %?, jcc
  1210                              <1> 	%endmacro
  1211                              <1> 	%imacro jae 1.nolist
  1212                              <1> 	%? %1
  1213                              <1> checksection %1, %?, jcc
  1214                              <1> 	%endmacro
  1215                              <1> 	%imacro jnae 1.nolist
  1216                              <1> 	%? %1
  1217                              <1> checksection %1, %?, jcc
  1218                              <1> 	%endmacro
  1219                              <1> 
  1220                              <1> 	%imacro jl 1.nolist
  1221                              <1> 	%? %1
  1222                              <1> checksection %1, %?, jcc
  1223                              <1> 	%endmacro
  1224                              <1> 	%imacro jnl 1.nolist
  1225                              <1> 	%? %1
  1226                              <1> checksection %1, %?, jcc
  1227                              <1> 	%endmacro
  1228                              <1> 	%imacro jle 1.nolist
  1229                              <1> 	%? %1
  1230                              <1> checksection %1, %?, jcc
  1231                              <1> 	%endmacro
  1232                              <1> 	%imacro jnle 1.nolist
  1233                              <1> 	%? %1
  1234                              <1> checksection %1, %?, jcc
  1235                              <1> 	%endmacro
  1236                              <1> 	%imacro jg 1.nolist
  1237                              <1> 	%? %1
  1238                              <1> checksection %1, %?, jcc
  1239                              <1> 	%endmacro
  1240                              <1> 	%imacro jng 1.nolist
  1241                              <1> 	%? %1
  1242                              <1> checksection %1, %?, jcc
  1243                              <1> 	%endmacro
  1244                              <1> 	%imacro jge 1.nolist
  1245                              <1> 	%? %1
  1246                              <1> checksection %1, %?, jcc
  1247                              <1> 	%endmacro
  1248                              <1> 	%imacro jnge 1.nolist
  1249                              <1> 	%? %1
  1250                              <1> checksection %1, %?, jcc
  1251                              <1> 	%endmacro
  1252                              <1> 
  1253                              <1> 	%imacro jo 1.nolist
  1254                              <1> 	%? %1
  1255                              <1> checksection %1, %?, jcc
  1256                              <1> 	%endmacro
  1257                              <1> 	%imacro jno 1.nolist
  1258                              <1> 	%? %1
  1259                              <1> checksection %1, %?, jcc
  1260                              <1> 	%endmacro
  1261                              <1> 	%imacro jp 1.nolist
  1262                              <1> 	%? %1
  1263                              <1> checksection %1, %?, jcc
  1264                              <1> 	%endmacro
  1265                              <1> 	%imacro jnp 1.nolist
  1266                              <1> 	%? %1
  1267                              <1> checksection %1, %?, jcc
  1268                              <1> 	%endmacro
  1269                              <1> 	%imacro jpe 1.nolist
  1270                              <1> 	%? %1
  1271                              <1> checksection %1, %?, jcc
  1272                              <1> 	%endmacro
  1273                              <1> 	%imacro jnpe 1.nolist
  1274                              <1> 	%? %1
  1275                              <1> checksection %1, %?, jcc
  1276                              <1> 	%endmacro
  1277                              <1> 	%imacro jpo 1.nolist
  1278                              <1> 	%? %1
  1279                              <1> checksection %1, %?, jcc
  1280                              <1> 	%endmacro
  1281                              <1> 	%imacro jnpo 1.nolist
  1282                              <1> 	%? %1
  1283                              <1> checksection %1, %?, jcc
  1284                              <1> 	%endmacro
  1285                              <1> 	%imacro js 1.nolist
  1286                              <1> 	%? %1
  1287                              <1> checksection %1, %?, jcc
  1288                              <1> 	%endmacro
  1289                              <1> 	%imacro jns 1.nolist
  1290                              <1> 	%? %1
  1291                              <1> checksection %1, %?, jcc
  1292                              <1> 	%endmacro
  1293                              <1> 
  1294                              <1> 	%imacro jcxz 1.nolist
  1295                              <1> 	%? %1
  1296                              <1> checksection %1, %?, jcc
  1297                              <1> 	%endmacro
  1298                              <1> 	%imacro jecxz 1.nolist
  1299                              <1> 	%? %1
  1300                              <1> checksection %1, %?, jcc
  1301                              <1> 	%endmacro
  1302                              <1> 	%imacro loop 1.nolist
  1303                              <1> 	%? %1
  1304                              <1> checksection %1, %?, jcc
  1305                              <1> 	%endmacro
  1306                              <1> 	%imacro loopz 1.nolist
  1307                              <1> 	%? %1
  1308                              <1> checksection %1, %?, jcc
  1309                              <1> 	%endmacro
  1310                              <1> 	%imacro loopnz 1.nolist
  1311                              <1> 	%? %1
  1312                              <1> checksection %1, %?, jcc
  1313                              <1> 	%endmacro
  1314                              <1> 	%imacro loope 1.nolist
  1315                              <1> 	%? %1
  1316                              <1> checksection %1, %?, jcc
  1317                              <1> 	%endmacro
  1318                              <1> 	%imacro loopne 1.nolist
  1319                              <1> 	%? %1
  1320                              <1> checksection %1, %?, jcc
  1321                              <1> 	%endmacro
  1322                              <1> %endif
  1323                              <1> 
  1324                              <1> 	%imacro checksection 3.nolist
  1325                              <1> %push
  1326                              <1>  %defstr %$string %1
  1327                              <1>  %substr %$shortword %$string 1, 5
  1328                              <1>  %substr %$shortsep %$string 6, 1
  1329                              <1>  %substr %$nearword %$string 1, 4
  1330                              <1>  %substr %$nearsep %$string 5, 1
  1331                              <1>  %substr %$farword %$string 1, 3
  1332                              <1>  %substr %$farsep %$string 4, 1
  1333                              <1>  %assign %$isshort 0
  1334                              <1>  %ifidni %$shortword, "short"
  1335                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1336                              <1>    %assign %$isshort 1
  1337                              <1>    %substr %$string %$string 7, -1
  1338                              <1>   %elif %$shortsep == '['
  1339                              <1>    %assign %$isshort 1
  1340                              <1>    %substr %$string %$string 6, -1
  1341                              <1>   %endif
  1342                              <1>  %endif
  1343                              <1>  %assign %$isnear 0
  1344                              <1>  %ifidni %$nearword, "near"
  1345                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1346                              <1>    %assign %$isnear 1
  1347                              <1>    %substr %$string %$string 6, -1
  1348                              <1>   %elif %$nearsep == '['
  1349                              <1>    %assign %$isnear 1
  1350                              <1>    %substr %$string %$string 5, -1
  1351                              <1>   %endif
  1352                              <1>  %endif
  1353                              <1>  %assign %$isfar 0
  1354                              <1>  %ifidni %$farword, "far"
  1355                              <1>   %if %$farsep == 32 || %$farsep == 9
  1356                              <1>    %assign %$isfar 1
  1357                              <1>    %substr %$string %$string 5, -1
  1358                              <1>   %elif %$farsep == '['
  1359                              <1>    %assign %$isfar 1
  1360                              <1>    %substr %$string %$string 4, -1
  1361                              <1>   %endif
  1362                              <1>  %endif
  1363                              <1> 
  1364                              <1>  %deftok %$token %$string
  1365                              <1> 
  1366                              <1>  %assign %$size 2
  1367                              <1>  %assign %$isreg 0
  1368                              <1>  %assign %$exit 0
  1369                              <1>  %rep 2
  1370                              <1>   %ifn %$exit
  1371                              <1>    %if %$size == 2
  1372                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1373                              <1>    %elif %$size == 4
  1374                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1375                              <1>    %endif
  1376                              <1>    %assign %$index 0
  1377                              <1>    %rep 8
  1378                              <1>     %ifn %$exit
  1379                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1380                              <1>      %deftok %$reg %$reg
  1381                              <1>      %ifnempty %$reg
  1382                              <1>       %ifidni %$reg, %$token
  1383                              <1>        %assign %$isreg %$size
  1384                              <1>        %assign %$exit 1
  1385                              <1>        %exitrep
  1386                              <1>       %endif
  1387                              <1>      %endif
  1388                              <1>     %endif
  1389                              <1>     %assign %$index %$index + 1
  1390                              <1>    %endrep
  1391                              <1>    %if %$exit
  1392                              <1>     %exitrep
  1393                              <1>    %endif
  1394                              <1>    %assign %$size %$size * 2
  1395                              <1>   %endif
  1396                              <1>  %endrep
  1397                              <1> 
  1398                              <1>  %assign %$ismulti 0
  1399                              <1>  %assign %$ismem 0
  1400                              <1>  %strlen %$length %$string
  1401                              <1>  %assign %$ii 0
  1402                              <1>  %rep %$length
  1403                              <1>   %substr %$point %$string %$ii + 1, 1
  1404                              <1>   %if %$point == 32 || %$point == 9
  1405                              <1>    %assign %$ismulti 1
  1406                              <1>   %endif
  1407                              <1>   %ifidn %$point, '['
  1408                              <1>    %assign %$ismem 1
  1409                              <1>   %endif
  1410                              <1>   %assign %$ii %$ii + 1
  1411                              <1>  %endrep
  1412                              <1> 
  1413                              <1>  %assign %$islocal 0
  1414                              <1>  %substr %$point %$string 1, 1
  1415                              <1>  %substr %$prefix %$string 1, 3
  1416                              <1>  %ifidn %$point, '.'
  1417                              <1>   %ifnidn %$prefix, '..@'
  1418                              <1>    %assign %$islocal 1
  1419                              <1>   %endif
  1420                              <1>  %endif
  1421                              <1> 
  1422                              <1>  %if %$isreg
  1423                              <1>   %if %$isreg == 4
  1424                              <1>    %warning 32-bit reg %3: %2 %1
  1425                              <1>   %else
  1426                              <1>    %warning 16-bit reg %3: %2 %1
  1427                              <1>   %endif
  1428                              <1>  %elif %$ismulti || %$ismem
  1429                              <1>   %warning not single %3: %2 %1
  1430                              <1>  %elif %$islocal
  1431                              <1>   %ifidni %3, call
  1432                              <1>    %warning local %3: %2 %1
  1433                              <1>   %endif
  1434                              <1>  %elifdef SECTION_OF_%[%$token]
  1435                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1436                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1437                              <1>   %endif
  1438                              <1>  %endif
  1439                              <1> %pop
  1440                              <1> 	%endmacro
  1441                              <1> 
  1442                              <1> 
  1443                              <1> 	struc MEMREF
  1444 00000000 ????????            <1> mrLinear:		resd 1
  1445 00000004 ????????            <1> mrOffset:		resd 1
  1446 00000008 ????                <1> mrSegmentSelector:	resw 1
  1447 0000000A ????                <1> mrFlags:		resw 1
  1448 0000000C ????????            <1> mrLength:		resd 1
  1449                              <1> 	endstruc
  1450                              <1> 
  1451                              <1> 		; Currently only direct branches are allowed when
  1452                              <1> 		;  disassembling from the U command. (That is,
  1453                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1454                              <1> 		;  types of references depend on segment registers
  1455                              <1> 		;  and sometimes base and index registers, which are
  1456                              <1> 		;  not known ahead of time. They are only known for
  1457                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1458                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1459                              <1> 		;  subsequent instruction using ss will not be
  1460                              <1> 		;  disassembled with the correct ss value.
  1461                              <1> 		;  This should be rare though. We may at a later
  1462                              <1> 		;  point detect this condition and not display
  1463                              <1> 		;  references with ss then.)
  1464                              <1> mrfBranchDirect:	equ    1
  1465                              <1> mrfMem:			equ    2
  1466                              <1> mrfMemSource:		equ    4
  1467                              <1> mrfMemDest:		equ    8
  1468                              <1> mrfA32:			equ   10h
  1469                              <1> mrfString:		equ   20h
  1470                              <1> mrfStringSource:	equ   40h
  1471                              <1> mrfStringDest:		equ   80h
  1472                              <1> mrfUsesSS:		equ  100h
  1473                              <1> mrfBranchIndirect:	equ  200h
  1474                              <1> 
  1475                              <1> 
  1476                              <1> %if _VXCHG && ! _VXCHGBIOS
  1477                              <1> 	struc XMSM
  1478 00000000 ????????            <1> .size_:		resd 1
  1479 00000004 ????                <1> .srchdl:	resw 1
  1480 00000006 ????????            <1> .srcadr:	resd 1
  1481 0000000A ????                <1> .dsthdl:	resw 1
  1482 0000000C ????????            <1> .dstadr:	resd 1
  1483                              <1> 	endstruc
  1484                              <1> %endif
  1485                              <1> 
  1486                              <1> 
  1487                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1488                              <1> 	;  cmd3_close_handle, so define it prior
  1489                              <1> %if _PM && _NOEXTENDER
  1490                              <1> %macro doscall 0
  1491                              <1> 	nearcall _doscall
  1492                              <1> %endmacro
  1493                              <1> %else
  1494                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1495                              <1> 		; are either in Real Mode or extended (all are real Int21
  1496                              <1> 		; instructions).
  1497                              <1> %macro doscall 0
  1498                              <1> 	int 21h
  1499                              <1> %endmacro
  1500                              <1> %endif
  1501                              <1> 
  1502                              <1> 
  1503                              <1> %if _LINK
  1504                              <1> %imacro wlcalc 1-2.nolist
  1505                              <1> %deftok %%filenametoken __FILE__
  1506                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1507                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1508                              <1> %endmacro
  1509                              <1> %endif
  1510                              <1> 
  1511                              <1> %if _BOOTLDR && _LINK
  1512                              <1> %macro lot_equate 2.nolist
  1513                              <1> LOAD_%2 equ %1
  1514                              <1> %endmacro
  1515                              <1> 
  1516                              <1> 	lot_equate    1, SET_DL_UNIT
  1517                              <1> 	lot_equate    2, SET_BL_UNIT
  1518                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1519                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1520                              <1> 	lot_equate  20h, PUSH_DPT
  1521                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1522                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1523                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1524                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1525                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1526                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1527                              <1> 	lot_equate 1000h, CMDLINE
  1528                              <1> 	lot_equate 2000h, NO_BPB
  1529                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1530                              <1> %endif
  1531                              <1> 
  1532                              <1> %if _HELP_COMPRESSED
  1533                              <1>  %assign NONCOMPRESSEDFLAG 1
  1534                              <1> %else
  1535                              <1>  %assign NONCOMPRESSEDFLAG 0
  1536                              <1> %endif
  1537                              <1> 
  1538                              <1> [list +]
  1539                              <1> 
  1540                              <1> %if _LINK
  1541                              <1>  %if _ONLY386
  1542                              <1> 	cpu 386
  1543                              <1>  %else
  1544                              <1> 	cpu 8086
  1545                              <1>  %endif
  1546                              <1> 
  1547                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1548                              <1> 	endarea auxbuff, 1
  1549                              <1> 
  1550                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1551                              <1> 	endarea auxbuff_max, 1
  1552                              <1> 
  1553                              <1> %if _INIT_MAX
  1554                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1555                              <1> %else
  1556                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1557                              <1> %endif
  1558                              <1> 	endarea auxbuff_init, 1
  1559                              <1> 
  1560                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1561                              <1> %endif
    20                                  %endif
    21                                  
    22                                  
    23                                  %if _LINK_COMPAT && _LOADER
    24                                  	usesection lDEBUG_DATA_ENTRY
    25                                  	align 16, db 0
    26                                  %endif
    27                                  
    28                                  	usesection lDEBUG_CODE
    28          ------------------       note: usesection lDEBUG_CODE
    29                                  
    30                                  ..@run_access_start:
    31                                  
    32                                  %if _LOADER
    33                                  gg:
    34                                  	dec si
    35                                  	dec si
    36                                  	mov dx, msg.goto
    37                                  	call isstring?
    38                                  	je cmd_goto
    39                                  	mov dx, msg.godebug
    40                                  	call isstring?
    41                                  	je godebug
    42                                  	inc si
    43                                  	lodsb
    44                                  	call chkeol
    45                                  	cmp byte [currentposition], 2		; hidden ?
    46                                  	je .runjust				; keep hooks -->
    47                                  	xor bp, bp
    48                                  	call moveloader_check_serial		; check unhook int 2Dh, serial
    49                                  
    50                                  	mov dx, msg.move_int_error
    51                                  	mov ax, 0293h
    52                                  	test bp, bp
    53                                  	jnz .specificerror
    54                                  
    55                                  	testopt [serial_flags], sf_init_done	; uninit serial I/O
    56                                  	jz @F
    57                                  	call serial_clean_up			; unhook interrupt
    58                                  	clropt [serial_flags], sf_init_done | sf_use_serial
    59                                  						; clear (in case return to cmd3)
    60                                  	; clropt [options], enable_serial	; do not output to serial any longer
    61                                  		; Leave DCO flag set so as to re-init serial I/O
    62                                  		;  if we're ever executed again.
    63                                  @@:
    64                                  	testopt [internalflags4], dif4_int_serial_hooked
    65                                  	jz .done_serial
    66                                  	call serial_uninstall_interrupt_handler
    67                                  	jnc .done_serial			; if it succeeded -->
    68                                  
    69                                  	mov di, msg.serial_cannot_unhook.int
    70                                  	mov al, byte [serial_installed_intnum]
    71                                  	call hexbyte
    72                                  	mov dx, msg.serial_cannot_unhook.nowarn
    73                                  	mov byte [serial_interrupt_handler + ieEOI], 0
    74                                  						; we do not issue EOI any longer
    75                                  	mov ax, 0294h
    76                                  .specificerror:
    77                                  	jmp moveloader.specificerror
    78                                  
    79                                  .done_serial:
    80                                  	testopt [internalflags4], dif4_int_2D_hooked
    81                                  	jz .done_2D
    82                                  	mov si, int2D
    83                                  	mov al, 2Dh
    84                                  	mov dx, opt4_int_2D_force >> 16
    85                                  	call UnhookInterruptForce
    86                                  	jnc @F
    87                                  	mov word [msg.serial_cannot_unhook.int], "2D"
    88                                  	mov dx, msg.serial_cannot_unhook.nowarn
    89                                  	mov ax, 0295h
    90                                  	jmp .specificerror
    91                                  
    92                                  @@:
    93                                  	clropt [internalflags4], dif4_int_2D_hooked
    94                                  	call update_inttab_optional
    95                                  				; (NC)
    96                                  .done_2D:
    97                                  
    98                                  .runjust:
    99                                  	jmp run
   100                                  
   101                                  godebug:
   102                                  	call skipwhite
   103                                  	call chkeol
   104                                  
   105                                  	cmp byte [currentposition], 2
   106                                  	je @F
   107                                  	mov dx, msg.loader_must_be_hidden
   108                                  	mov ax, 028Ah
   109                                  .specificerror:
   110                                  	push ss
   111                                  	pop ds
   112                                  	push ss
   113                                  	pop ds
   114                                  	call setrc
   115                                  	jmp putsz_error
   116                                  
   117                                  @@:
   118                                  	mov es, word [reg_cs]
   119                                  	mov di, word [reg_eip]
   120                                  	push cs
   121                                  	pop ds
   122                                  	mov si, entrypattern
   123                                  	mov cx, entrypattern.size
   124                                  	repe cmpsb
   125                                  	je .foundentry
   126                                  	mov dx, msg.loader_extra
   127                                  	mov ax, 028Bh
   128                                  	jmp .specificerror
   129                                  
   130                                  .foundentry:
   131                                  	 push ss
   132                                  	 pop ds
   133                                  	mov es, word [reg_ss]
   134                                  	mov di, word [reg_ebp]		; -> lsv
   135                                  	mov cx, word [es:di + lsvLoadSeg]
   136                                  	mov ax, word [reg_cs]
   137                                  	add ax, paras(4096)		; minimum expected
   138                                  	jc .overflow
   139                                  	cmp cx, ax
   140                                  	jae @F
   141                                  .overflow:
   142                                  	mov dx, msg.loader_loadseg_low
   143                                  	mov ax, 028Dh
   144                                  	jmp .specificerror
   145                                  @@:
   146                                  	mov ax, word [reg_cs]
   147                                  	add ax, paras(24 * 1024)	; clamp here
   148                                  	jc @F
   149                                  	cmp cx, ax
   150                                  	jbe @F
   151                                  	mov cx, ax
   152                                  @@:
   153                                  	mov ax, word [reg_cs]
   154                                  	sub cx, ax			; = amount paragraphs
   155                                  .scanloop:
   156                                  	mov es, ax
   157                                  	xor di, di
   158                                  	push cx
   159                                  	mov si, msg.loadsupportsignature
   160                                  	mov cx, msg.loadsupportsignature.size
   161                                  	repe cmpsb
   162                                  	pop cx
   163                                  	je .foundsignature
   164                                  	inc ax
   165                                  	loop .scanloop
   166                                  	mov dx, msg.loader_sign
   167                                  	mov ax, 028Eh
   168                                  	jmp .specificerror
   169                                  
   170                                  .foundsignature:
   171                                  	test byte [es:di], -1
   172                                  	jz .noflag
   173                                  	mov dx, msg.loader_flag
   174                                  	mov ax, 028Fh
   175                                  	jmp .specificerror
   176                                  
   177                                  .noflag:
   178                                  	xor ax, ax
   179                                  	mov word [reg_eax], ax		; pass ax as zero
   180                                  	mov di, word [reg_esp]
   181                                  	mov ax, word [reg_ebp]
   182                                  	mov es, word [reg_ss]
   183                                  	mov bx, ax
   184                                  	sub ax, di
   185                                  	ja @FF
   186                                  @@:
   187                                  	mov dx, msg.loader_stack
   188                                  	mov ax, 028Ch
   189                                  	jmp .specificerror
   190                                  @@:
   191                                  	cmp ax, - LOADSTACKVARS
   192                                  	jb @BB
   193                                  	cmp ax, - lsvCommandLine
   194                                  	jae @F
   195                                  	sub word [reg_esp], 4
   196                                  	and word [es:bx + lsvCommandLine], 0
   197                                  	and word [es:bx + lsvExtra], 0
   198                                  @@:
   199                                  
   200                                  	setopt [es:bx + lsvExtra.flags], lsvefPreserveLoader
   201                                  	add word [reg_eip], entrypattern.size
   202                                  	clropt [reg_efl], 100h | 200h | 400h	; clear TF, IF and DF
   203                                  	 push ss
   204                                  	 pop es
   205                                  	jmp run
   206                                  
   207                                  
   208                                  entrypattern:
   209                                  .:		; Expected at 200h:400h to allow passing a
   210                                  		;  nonzero lsvExtra to the initial loader.
   211                                  		;  This code is skipped if found.
   212                                  	cli
   213                                  	cld
   214                                  	xor ax, ax
   215                                  	push ax
   216                                  	mov word [bp + lsvExtra], ax
   217                                  	push ax
   218                                  .size equ $ - .
   219                                  
   220                                  
   221                                  %endif
   222                                  
   223                                  %if !_LOADER
   224                                  gg_repeat:
   225 00000000 E8(0000)                	call guard_re
   226 00000003 800E[0000]20            	setopt [internalflags2], dif2_gg_again
   227 00000008 EB17                    	jmp @F
   228                                  
   229                                  		; G command - go.
   230                                  gg:
   231 0000000A 4E                      	dec si
   232 0000000B 4E                      	dec si
   233 0000000C BA[0000]                	mov dx, msg.goto
   234 0000000F E8(0000)                	call isstring?
   235 00000012 7503E9(0000)            	je cmd_goto
   236 00000017 46                      	inc si
   237 00000018 AC                      	lodsb
   238                                  
   239 00000019 E8(0000)                	call guard_re
   240                                  
   241 0000001C 8026[0000]DF            	clropt [internalflags2], dif2_gg_again
   242                                  @@:
   243 00000021 C706[0000][0000]        	mov word [gg_deferred_message], msg.empty_message
   244 00000027 8326[0000]00            	and word [bb_deferred_message_in_lineout_behind], 0
   245                                  
   246 0000002C BB[0000]                	mov bx, dmycmd
   247 0000002F F606[0200]02            	testopt [options], gg_no_autorepeat
   248 00000034 7503                    	jnz @F
   249 00000036 BB[0000]                	mov bx, gg_repeat
   250                                  @@:
   251 00000039 891E[0000]              	mov word [lastcmd], bx
   252                                  
   253 0000003D 800E[0000]08            	setopt [internalflags2], dif2_gg_is_gg
   254 00000042 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
   257                                  
   258 00000047 FF36[0000]              	push word [reg_cs]	; save original CS
   259 0000004B 8F06[0400]              	pop word [eqladdr+4]
   260 0000004F E81E1B                  	call parseql		; process =addr
   261                                  
   262 00000052 F606[0200]01            	testopt [options], gg_do_not_skip_bp
   263 00000057 752C                    	jnz .do_not_skip_cseip
   264 00000059 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
   265                                  
   266 0000005E 803E[0000]00            	cmp byte [eqflag], 0
   267 00000063 7508                    	jne .cseip_take_eql
   268                                  
   269 00000065 66                      	_386_PM_o32		; xor ecx, ecx
   270 00000066 31C9                    	xor cx, cx
   271 00000068 E84F08                  	call get_cseip_ecx_linear
   272 0000006B EB0C                    	jmp .got_cseip
   273                                  
   274                                  .cseip_take_eql:
   275 0000006D 8B1E[0400]              	mov bx, word [eqladdr + 4]
   276 00000071 66                      	_386_PM_o32		; mov edx, dword [eqladdr]
   277 00000072 8B16[0000]              	mov dx, word [eqladdr]
   278 00000076 E84D08                  	call getlinear_d_b
   279                                  .got_cseip:
   280 00000079 7303E9(0000)            	jc error
   281 0000007E A3[0000]                	mov word [gg_first_cseip_linear], ax
   282 00000081 8916[0200]              	mov word [gg_first_cseip_linear + 2], dx
   283                                  .do_not_skip_cseip:
   284                                  
   285                                  %ifn _NUM_G_BP
   286                                  	call chkeol
   287                                  
   288                                  	testopt [options3], opt3_gg_no_paging
   289                                  	jz @F
   290                                  	clropt [internalflags], pagedcommand
   291                                  @@:
   292                                  	call tpg_initialise_empty_auxbuff
   293                                  
   294                                  %if _BREAKPOINTS
   295                                  	call bb_writepoints_init_reset
   296                                  %endif
   297                                  
   298                                  %else
   299 00000085 4E                      	dec si
   300 00000086 E8(0000)                	call skipcomma
   301 00000089 4E                      	dec si
   302 0000008A BA[0000]                	mov dx, msg.again
   303 0000008D E8(0000)                	call isstring?
   304 00000090 752B                    	jne @F			; (after this, do not dec si!)
   305                                  
   306                                  gg_again:
   307                                  
   308                                  %if _WHILEBUFFSIZE < (BPSIZE * _NUM_G_BP + 1)
   309                                   %error WHILE buffer not large enough for gg breakpoint list
   310                                  %endif
   311                                  
   312 00000092 56                      	push si
   313 00000093 BE[0000]                	mov si, g_bplist.used_count
   314 00000096 31C0                    	xor ax, ax
   315 00000098 AC                      	lodsb			; ax = number of breakpoints set yet
   316 00000099 4E                      	dec si			; -> gg breakpoint list
   317 0000009A 89C1                    	mov cx, ax
   318 0000009C 01C9                    	add cx, cx
   319 0000009E 01C9                    	add cx, cx		; * 4
   320                                  %if BPSIZE == 4
   321                                  %elif BPSIZE == 5
   322                                  	add cx, ax		; * 5
   323                                  %elif BPSIZE == 6
   324                                  	add cx, ax		; * 5
   325                                  	add cx, ax		; * 6
   326                                  %elif BPSIZE == 9
   327 000000A0 01C9                    	add cx, cx		; * 8
   328 000000A2 01C1                    	add cx, ax		; * 9
   329                                  %else
   330                                   %error Unexpected breakpoint size
   331                                  %endif
   332 000000A4 41                      	inc cx			; include the count
   333 000000A5 BF[0000]                	mov di, while_buffer	; es:di -> WHILE buffer
   334 000000A8 F3A4                    	rep movsb		; initialise WHILE buffer list
   335                                  
   336 000000AA 5E                      	pop si			; si -> separator after "AGAIN" keyword
   337 000000AB BF[0100]                	mov di, while_buffer + 1	; -> first point
   338 000000AE 89C1                    	mov cx, ax
   339 000000B0 B0CC                    	mov al, 0CCh
   340 000000B2 E306                    	jcxz .end
   341                                  .loop:
   342 000000B4 83C708                  	add di, BPSIZE - 1	; -> point content
   343 000000B7 AA                      	stosb			; initialise breakpoint content
   344 000000B8 E2FA                    	loop .loop
   345                                  .end:
   346                                  				; es:di -> after last breakpoint in array
   347 000000BA E9AC00                  	jmp gg3			; parse additional points (do not dec si!)
   348                                  
   349                                  @@:
   350 000000BD F606[0000]20            	testopt [internalflags2], dif2_gg_again
   351 000000C2 75CE                    	jnz gg_again
   352                                  
   353                                  
   354                                  gg_list:
   355 000000C4 BA[0000]                	mov dx, msg.list
   356 000000C7 E8(0000)                	call isstring?
   357 000000CA 7403E99400              	jne .not
   358                                  
   359 000000CF AC                      	lodsb
   360 000000D0 E8(0000)                	call chkeol
   361                                  
   362 000000D3 800E[0000]05            	setopt [internalflags2], dif2_gg_is_first | dif2_gg_skip_cseip
   363                                  
   364 000000D8 BE[0000]                	mov si, g_bplist.bp
   365 000000DB 31C9                    	xor cx, cx
   366 000000DD 8A4CFF                  	mov cl, byte [si - 1]
   367 000000E0 31DB                    	xor bx, bx
   368 000000E2 E379                    	jcxz .none
   369                                  .loop:
   370 000000E4 43                      	inc bx
   371 000000E5 51                      	push cx
   372 000000E6 53                      	push bx
   373                                  
   374 000000E7 89D8                    	mov ax, bx		; 1-based index
   375 000000E9 BF[0000]                	mov di, line_out
   376 000000EC E83407                  	call ordinalbyte
   377                                  
   378 000000EF 57                      	push di
   379 000000F0 81EF[0300]              	sub di, line_out + 1 + 2
   380                                  				; 1 = a digit, 2 = ordinal suffix,
   381                                  				; result = how many additional digits are used
   382 000000F4 BA[0000]                	mov dx, msg.list_bp.first
   383 000000F7 01FA                    	add dx, di
   384 000000F9 E8(0000)                	call putsz		; show blanks first
   385 000000FC 5F                      	pop di
   386 000000FD E8(0000)                	call putsline
   387                                  
   388 00000100 E89204                  	call gg_bb_lods_bp_linear
   389                                  				; BPSIZE implied
   390                                  
   391 00000103 BF[0000]                	mov di, msg.list_bp.address1
   392 00000106 92                      	xchg ax, dx
   393 00000107 E8(0000)                	call hexword
   394 0000010A 47                      	inc di
   395                                  	; mov di, msg.list_bp.address2
   396 0000010B 92                      	xchg ax, dx
   397 0000010C E8(0000)                	call hexword
   398                                  
   399 0000010F E8D706                  	call gg_bb_check_is_first
   400                                  				; we set up the dif2_gg_skip_cseip flag,
   401 00000112 B9[0000]                	mov cx, msg.list_bp_not_cseip
   402                                  				;  so if CY (do not skip), initialise this
   403 00000115 721C                    	jc .not_cseip
   404                                  				;  if NC (do skip), use other string
   405                                  %if _PM
   406 00000117 53                      	push bx
   407 00000118 8B1E[0000]              	mov bx, word [reg_cs]
   408 0000011C 803E[0000]00            	cmp byte [eqflag], 0
   409 00000121 7404                    	je @F
   410 00000123 8B1E[0400]              	mov bx, word [eqladdr + 4]
   411                                  @@:
   412 00000127 E8(0000)                	call test_d_b_bit
   413 0000012A 5B                      	pop bx
   414 0000012B B9[0000]                	mov cx, msg.list_bp_cseip_32
   415 0000012E 7503                    	jnz @F			; if 32-bit cs -->
   416                                  %endif
   417 00000130 B9[0000]                	mov cx, msg.list_bp_csip_16
   418                                  @@:
   419                                  .not_cseip:
   420                                  %if BPSIZE == 6 || BPSIZE == 9
   421                                  		; INP:	dx:ax = linear address
   422                                  		;	si -> (d)word offset
   423                                  		;	di -> where to store
   424                                  		; OUT:	cx = length displayed
   425                                  		;	si -> after offset
   426                                  		;	di -> after stored string
   427                                  		; CHG:	ax, dx
   428 00000133 51                      	push cx
   429 00000134 BF[0000]                	mov di, line_out
   430 00000137 E8(0000)                	call bp_display_offset	; BPSIZE implied
   431 0000013A 57                      	push di
   432                                  %endif
   433 0000013B BF[0000]                	mov di, msg.list_bp.value
   434 0000013E AC                      	lodsb			; BPSIZE implied
   435 0000013F E8(0000)                	call hexbyte
   436                                  
   437 00000142 BA[0000]                	mov dx, msg.list_bp.second
   438 00000145 E8(0000)                	call putsz
   439                                  
   440                                  %if BPSIZE == 6 || BPSIZE == 9
   441 00000148 5F                      	pop di
   442 00000149 E8(0000)                	call putsline
   443 0000014C 59                      	pop cx
   444                                  %endif
   445                                  
   446 0000014D BA[0000]                	mov dx, msg.list_bp.third
   447 00000150 E8(0000)                	call putsz
   448                                  
   449 00000153 89CA                    	mov dx, cx
   450 00000155 E8(0000)                	call putsz
   451                                  
   452 00000158 5B                      	pop bx
   453 00000159 59                      	pop cx
   454 0000015A E288                    	loop .loop
   455                                  .end:
   456                                  	; mov dx, msg.list_bp_first_detected
   457                                  	; testopt [internalflags2], dif2_gg_first_detected
   458                                  	; jnz .putsz
   459 0000015C C3                      	retn
   460                                  
   461                                  .none:
   462 0000015D BA[0000]                	mov dx, msg.list_bp_none
   463                                  .putsz:
   464 00000160 E9(0000)                	jmp putsz
   465                                  
   466                                  .not:
   467                                  
   468                                  		; Store the address of each breakpoint into the buffer. We also
   469                                  		; make sure that there aren't too many breakpoints. (The user can
   470                                  		; specify them with 2 byte per breakpoints which gives about 128
   471                                  		; breakpoints with a full command line.) The breakpoints will only
   472                                  		; be set later when we have verified that the line contains no
   473                                  		; syntax errors and that there aren't too many breakpoints.
   474                                  		;
   475                                  		; Note:	With "G AGAIN" (or the gg_repeat handler), the user
   476                                  		;	 can actually specify an arbitrary amount of
   477                                  		;	 breakpoints. However, we limit the amount.
   478                                  %if _WHILEBUFFSIZE < (BPSIZE * _NUM_G_BP + 1)
   479                                   %error WHILE buffer not large enough for gg breakpoint list
   480                                  %endif
   481 00000163 BF[0000]                	mov di, while_buffer	; es:di -> WHILE buffer
   482 00000166 31C0                    	xor ax, ax
   483 00000168 AA                      	stosb			; counter of saved breakpoints
   484                                  gg3:
   485                                  	; dec si		; don't use skipcomm0 instead - need to restore al
   486 00000169 E8(0000)                	call skipcomma
   487 0000016C E8(0000)                	call iseol?
   488 0000016F 7446                    	je gg4			; if done -->
   489                                  
   490 00000171 4E                      	dec si
   491 00000172 BA[0000]                	mov dx, msg.remember
   492 00000175 E8(0000)                	call isstring?
   493 00000178 AC                      	lodsb
   494 00000179 7510                    	jne @F
   495                                  
   496 0000017B E8(0000)                	call chkeol
   497 0000017E 89F9                    	mov cx, di		; -> after last point
   498 00000180 BE[0000]                	mov si, while_buffer	; ds:si -> WHILE buffer
   499 00000183 29F1                    	sub cx, si		; = size of list
   500 00000185 BF[0000]                	mov di, g_bplist.used_count
   501                                  				; es:di -> gg breakpoint list
   502 00000188 F3A4                    	rep movsb		; copy list over
   503 0000018A C3                      	retn
   504                                  
   505                                  @@:
   506 0000018B 8B1E[0400]              	mov bx, word [eqladdr+4]; default segment
   507 0000018F E8A907                  	call getlinearaddr	; get linear address into bx:dx (CHG edx)
   508 00000192 7303E9(0000)            	jc error
   509 00000197 803E[0000]10            	cmp byte [while_buffer], _NUM_G_BP
   510 0000019C 7203E9(0000)            	jae error		; can't store another breakpoint, g_bplist is full -->
   511 000001A1 92                      	xchg ax, dx		; ax = low word
   512 000001A2 AB                      	stosw
   513 000001A3 93                      	xchg ax, bx		; to store high byte/word
   514                                  %if _PM
   515 000001A4 AB                      	stosw
   516                                  %else
   517                                  	stosb			; bits 24-31 (dh) always zero in 21-bit addresses
   518                                  %endif
   519                                  				; BPSIZE implied
   520                                  %if BPSIZE == 6
   521                                  	mov ax, word [bp_offset]
   522                                  	stosw			; write offset (R86M-only 16-bit)
   523                                  %elif BPSIZE == 9
   524 000001A5 A1[0000]                	mov ax, word [bp_offset]
   525 000001A8 AB                      	stosw
   526 000001A9 A1[0200]                	mov ax, word [bp_offset + 2]
   527 000001AC AB                      	stosw			; write offset (PM 32-bit)
   528                                  %endif
   529 000001AD B0CC                    	mov al, 0CCh
   530 000001AF AA                      	stosb			; later filled with the byte read from this address
   531 000001B0 FE06[0000]              	inc byte [while_buffer]	; increment count
   532 000001B4 4E                      	dec si
   533 000001B5 EBB2                    	jmp short gg3
   534                                  
   535                                  gg4:
   536 000001B7 89F9                    	mov cx, di		; -> after last point
   537 000001B9 BE[0000]                	mov si, while_buffer	; ds:si -> WHILE buffer
   538 000001BC 29F1                    	sub cx, si		; = size of list
   539 000001BE BF[0000]                	mov di, g_bplist.used_count
   540                                  				; es:di -> gg breakpoint list
   541 000001C1 F3A4                    	rep movsb		; copy list over
   542                                  
   543                                  %if _RH
   544 000001C3 E8(0000)                	call enable_rh
   545                                  %endif
   546                                  
   547 000001C6 F606[0000]08            	testopt [options3], opt3_gg_no_paging
   548 000001CB 7405                    	jz @F
   549 000001CD 8026[0000]F7            	clropt [internalflags], pagedcommand
   550                                  @@:
   551                                  
   552                                  gg5:
   553 000001D2 E88319                  	call tpg_initialise_empty_auxbuff
   554                                  %if _BREAKPOINTS
   555 000001D5 E83D04                  	call bb_writepoints_init_reset
   556                                  				; try to write bb points
   557                                  				; (detect and write to cseip point too)
   558                                  		; If this fails, it handles the errors and tries to restore
   559                                  		; all its own points, then aborts the command.
   560                                  
   561                                  		; This call might return modeswitched.
   562                                  %endif
   563 000001D8 BE[0000]                	mov si, g_bplist.used_count
   564 000001DB 31C0                    	xor ax, ax
   565 000001DD AC                      	lodsb			; si-> first point
   566 000001DE 89C1                    	mov cx, ax		; cx = number of saved breakpoints
   567 000001E0 51                      	push cx
   568 000001E1 E8A805                  	call gg_writepoints	; Store breakpoint bytes in the given locations.
   569 000001E4 5A                      	pop dx
   570                                  		; dx = number of points tried to write
   571                                  		; cx = number of points not written
   572 000001E5 7342                    	jnc .points_set		; successful -->
   573                                  
   574                                  
   575                                  		; Failure to write to a gg breakpoint. Now the fun starts!
   576 000001E7 29CA                    	sub dx, cx		; = number of points written
   577 000001E9 89D1                    	mov cx, dx
   578                                  			; We now first have to try restoring all the points we
   579                                  			; already set because they might be inside the DOS or
   580                                  			; BIOS handlers we would otherwise call. So instead of
   581                                  			; displaying errors as we detect them, all the intel is
   582                                  			; stored first until all points have been taken care of
   583                                  			; (if possible). We then display error messages.
   584                                  %if _BREAKPOINTS
   585 000001EB 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   586                                  				; reserve space for bb error info
   587                                  %endif
   588 000001EE 89E5                    	mov bp, sp		; -> behind gg error info, -> bb error info
   589 000001F0 01D2                    	add dx, dx
   590 000001F2 29D4                    	sub sp, dx		; reserve space for gg error info
   591 000001F4 50                      	push ax			; store error info on point that failed to be written
   592                                  
   593                                  		; The gg points were written last, so restore them first.
   594 000001F5 E89B04                  	call gg_restorepoints_and_init_error_info
   595                                  %if _BREAKPOINTS
   596 000001F8 51                      	push cx
   597                                  		; Next, restore the bb points.
   598 000001F9 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   599                                  				; = index above last one to restore
   600 000001FC E8E404                  	call bb_restorepoints_and_init_error_info
   601 000001FF 59                      	pop cx			; (preserve index of failed gg point)
   602                                  %endif
   603 00000200 58                      	pop ax
   604                                  
   605 00000201 E8AB01                  	call put_deferred_message_silent
   606                                  				; CHG: dx
   607                                  
   608                                  		; ax = info on initially failed point
   609                                  		; cx = 0-based index of initially failed point
   610                                  		;    = number of points tried to restore
   611 00000204 89CE                    	mov si, cx
   612 00000206 01F6                    	add si, si
   613 00000208 01F6                    	add si, si		; *4
   614                                  %if BPSIZE == 4
   615                                  %elif BPSIZE == 5
   616                                  	add si, cx		; * 5
   617                                  %elif BPSIZE == 6
   618                                  	add si, cx		; * 5
   619                                  	add si, cx		; * 6
   620                                  %elif BPSIZE == 9
   621 0000020A 01F6                    	add si, si		; * 8
   622 0000020C 01CE                    	add si, cx		; * 9
   623                                  %else
   624                                   %error Unexpected breakpoint size
   625                                  %endif
   626 0000020E 81C6[0000]              	add si, g_bplist.bp
   627                                  
   628                                  		; si-> point
   629                                  		; ax = info (ah = reason, al = new value if reason 3)
   630                                  		; cx = 0-based index of initially failed point
   631 00000212 51                      	push cx
   632 00000213 FF7402                  	 push word [si + 2]
   633 00000216 FF34                    	 push word [si]		; stack: linear address
   634 00000218 BB0080                  	mov bx, 8000h		; bh = 80h (gg),
   635                                  				;  bl = what we tried to restore (n/a)
   636 0000021B E8D712                  	call display_breakpoint_failure
   637 0000021E 59                      	pop cx
   638 0000021F E85B06                  	call gg_handlefailedrestore
   639                                  %if _BREAKPOINTS
   640 00000222 E82606                  	call bb_handlefailedrestore
   641 00000225 8D6620                  	lea sp, [bp + (_NUM_B_BP + _NUM_SYM_BP) * 2]
   642                                  %else
   643                                  	mov sp, bp
   644                                  %endif
   645                                  				; (discard bb + gg error info)
   646 00000228 C3                      	retn
   647                                  
   648                                  
   649                                  .points_set:
   650                                  		; All bb and gg points were successfully written.
   651                                  		;  Next: Handle cseip case, if such a point has been detected.
   652                                  
   653                                  
   654                                  ; old cseip breakpoint handling comment:
   655                                  ; interrupt ? emuint : .isstdtrace (including DPMI hack, pushf handling)
   656                                  
   657                                  %endif	; _NUM_G_BP
   658                                  
   659                                  
   660                                  %if _NUM_G_BP || _BREAKPOINTS
   661 00000229 F606[0000]10            	testopt [internalflags2], dif2_gg_first_detected
   662 0000022E 7503E91D01              	jz .only_run		; easy case, no cseip point detected -->
   663                                  
   664                                  
   665                                  		; Enter special mode: Restore cseip breakpoint content.
   666 00000233 800E[0000]02            	setopt [internalflags2], dif2_gg_skip_non_cseip
   667                                  
   668 00000238 89D1                    	mov cx, dx		; = number of points set
   669                                  %if _BREAKPOINTS
   670 0000023A 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   671                                  %endif
   672 0000023D 89E5                    	mov bp, sp		; -> behind error info
   673                                  %if _NUM_G_BP
   674 0000023F 89CA                    	mov dx, cx
   675 00000241 01D2                    	add dx, dx
   676 00000243 29D4                    	sub sp, dx
   677 00000245 E84B04                  	call gg_restorepoints_and_init_error_info
   678                                  
   679 00000248 7326                    	jnc .gg_restore_cseip_success
   680                                  
   681                                  
   682                                  		; Error in gg_restorepoints. Try to restore other gg, all bb.
   683                                  
   684                                  		; Exit special mode: Handle non-cseip breakpoints again.
   685 0000024A 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
   686                                  
   687                                  		; Enter special mode: Skip cseip breakpoints.
   688 0000024F 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
   689                                  
   690                                  		; As we already tried to restore all cseip gg points,
   691                                  		;  here we skip these in the gg_restorepoints call.
   692 00000254 E83F04                  	call gg_restorepoints
   693                                  
   694                                  		; Exit special mode: No longer skip cseip breakpoints.
   695 00000257 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
   696                                  
   697                                  		; Any cseip bb points aren't yet restored, so do not skip them.
   698                                  %if _BREAKPOINTS
   699 0000025C 51                      	push cx
   700 0000025D B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   701 00000260 E88004                  	call bb_restorepoints_and_init_error_info
   702 00000263 59                      	pop cx
   703                                  %endif
   704                                  %else
   705                                  	jmp .gg_restore_cseip_success
   706                                  %endif
   707                                  
   708                                  .gg_bb_cseip_fail_common:
   709                                  		; The failure that led us here is already noted in the info.
   710                                  %if _NUM_G_BP
   711 00000264 E81606                  	call gg_handlefailedrestore
   712                                  %endif
   713                                  %if _BREAKPOINTS
   714 00000267 E8E105                  	call bb_handlefailedrestore
   715                                  %endif
   716                                  %if _NUM_G_BP
   717                                   %if _BREAKPOINTS
   718 0000026A 8D6620                  	lea sp, [bp + (_NUM_B_BP + _NUM_SYM_BP) * 2]
   719                                   %else
   720                                  	mov sp, bp
   721                                   %endif
   722                                  %elif _BREAKPOINTS
   723                                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   724                                  %endif
   725 0000026D E9(0000)                	jmp cmd3
   726                                  
   727                                  .gg_restore_cseip_success:
   728                                  %if _BREAKPOINTS
   729 00000270 B91000                  	mov cx, (_NUM_B_BP + _NUM_SYM_BP)
   730                                  				; = index above last one to restore
   731 00000273 E86D04                  	call bb_restorepoints_and_init_error_info
   732 00000276 7322                    	jnc @F			; no error ? -->
   733                                  
   734                                  		; Error in bb_restorepoints. Try to restore other gg, other bb.
   735                                  
   736                                  		; Exit special mode: Handle non-cseip breakpoints again.
   737 00000278 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
   738                                  
   739                                  		; Enter special mode: Skip cseip breakpoints.
   740 0000027D 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
   741                                  
   742                                  		; As we already tried to restore all cseip gg and bb points,
   743                                  		;  here we skip these in the bb_restorepoints call.
   744                                  %if _NUM_G_BP
   745 00000282 31C9                    	xor cx, cx
   746 00000284 8A0E[0000]              	mov cl, byte [g_bplist.used_count]
   747 00000288 E80B04                  	call gg_restorepoints
   748 0000028B 51                      	push cx
   749                                  %endif
   750 0000028C B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   751 0000028F E85404                  	call bb_restorepoints
   752                                  %if _NUM_G_BP
   753 00000292 59                      	pop cx
   754                                  %endif
   755                                  
   756                                  		; Exit special mode: No longer skip cseip breakpoints.
   757 00000293 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
   758                                  
   759 00000298 EBCA                    	jmp .gg_bb_cseip_fail_common
   760                                  
   761                                  @@:
   762                                  		; Success! Now discard the reserved error info.
   763 0000029A 8D6620                  	lea sp, [bp + (_NUM_B_BP + _NUM_SYM_BP) * 2]
   764                                  %else
   765                                  	mov sp, bp
   766                                  %endif
   767                                  
   768                                  		; Special mode restoration handled. Now trace one instruction.
   769                                  		;  (Proceed if repeated string op or interrupt.)
   770                                  %if _PM
   771 0000029D E87407                  	call resetmode
   772                                  %endif
   773 000002A0 E8F018                  	call seteq		; make the = operand take effect
   774 000002A3 BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
   775 000002A6 8B1E[0000]              	mov bx, word [reg_cs]
   776 000002AA 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
   777 000002AB 8B36[0000]              	mov si, word [reg_eip]
   778                                  .pp2:
   779 000002AF E8A213                  	call pp16		; get next instruction byte into AL
   780 000002B2 BF[0000]                	mov di, ppbytes
   781 000002B5 B9[0000]                	mov cx, PPLEN_ONLY_STRING
   782                                  %if _SYMBOLIC
   783                                  	mov byte [pp_instruction], al
   784                                  %endif
   785 000002B8 F2AE                    	repne scasb
   786 000002BA 752E                    	jne .not_p		; if not one of these -->
   787                                  %if _LINK_COMPAT
   788 000002BC 8A85[FFFF]              	mov al,byte [word di+PPLEN-1]; get corresponding byte in ppinfo
   789                                  %else
   790                                  	mov al,byte [di+PPLEN-1]; get corresponding byte in ppinfo
   791                                  %endif
   792 000002C0 A880                    	test al, PP_PREFIX	; prefix ?
   793 000002C2 740E                    	jz .pp3			; no -->
   794 000002C4 08C6                    	or dh, al		; set the OSIZE or ASIZE flags if either of these
   795                                  			; Note:	Multiple OSIZE in a 16-bit cs do not toggle
   796                                  			;	between decoding as O32 and O16, they're always
   797                                  			;	decoded as O32. The same is true for A32, and
   798                                  			;	in a 32-bit cs for O16 and A16.
   799 000002C6 FECA                    	dec dl
   800 000002C8 75E5                    	jnz .pp2		; if not out of bytes -->
   801 000002CA C706[0000][0000]        	mov word [gg_deferred_message], msg.warnprefix
   802 000002D0 EB18                    	jmp .not_p
   803                                  
   804                                  		; A repeatable string instruction is to be decoded.
   805                                  		; Finish the decoding and skip the appropriate number
   806                                  		; of opcode bytes.
   807                                  .pp3:
   808 000002D2 E8200F                  _386_PM	call pp_fix32bitflags
   809 000002D5 A847                    	test al, PP_VARSIZ | PP_SIZ_MASK
   810 000002D7 7403E9(0000)            	jnz error
   811                                  %if 0
   812                                  	test al, PP_VARSIZ	; different opcode length depends on OSIZE ?
   813                                  	jz .ignoreosize		; no -->
   814                                  	and dh, 2
   815                                  	add al, dh
   816                                  .ignoreosize:
   817                                  	and ax, PP_SIZ_MASK
   818                                  _386_PM	movzx eax, ax		; clear high word (in case it counts)
   819                                  	_386_PM_o32	; add esi, eax
   820                                  	add si, ax
   821                                  %endif
   822                                  ; pp10:
   823                                  %if _SYMBOLIC
   824                                  	call pp3_check_symhints
   825                                  	jc .not_p		; trace -->
   826                                  %endif
   827                                  	; jmp short pp11	; we have a skippable instruction here
   828                                  ; pp11:
   829 000002DC E8(0000)                _386_PM	call test_d_b_bit
   830 000002DF 7504                    _386_PM	jnz .32			; full 32-bit offset valid -->
   831 000002E1 660FB7F6                _386_PM	movzx esi, si		; clear high word here
   832                                  .32:
   833 000002E5 E8D612                  	call proceedbreakpoint	; run until the breakpoint is hit
   834                                  		; This call might return modeswitched.
   835 000002E8 EB03                    	jmp short @F
   836                                  
   837                                  .not_p:
   838 000002EA E8220D                  	call traceone		; call common code
   839                                  @@:
   840 000002ED 9C                      	pushf
   841                                  
   842                                  		; Exit special mode, do not skip non-cseip breakpoints anymore.
   843 000002EE 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
   844                                  
   845                                  		; Enter special mode: Skip matching/restoring cseip breakpoint.
   846 000002F3 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
   847                                  
   848 000002F8 F6C47F                  	test ah, 7Fh		; error happened during proceedbreakpoint ?
   849 000002FB 7440                    	jz @F			; no -->
   850                                  
   851 000002FD 59                      	pop cx			; (discard flags on stack)
   852                                  
   853                                  %if _NUM_G_BP
   854 000002FE 31C9                    	xor cx, cx
   855 00000300 8A0E[0000]              	mov cl, byte [g_bplist.used_count]
   856                                  %endif
   857                                  
   858                                  %if _BREAKPOINTS
   859 00000304 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   860                                  				; reserve space for bb error info
   861                                  %endif
   862 00000307 89E5                    	mov bp, sp		; -> behind gg error info, -> bb error info
   863                                  %if _NUM_G_BP
   864 00000309 89CA                    	mov dx, cx
   865 0000030B 01D2                    	add dx, dx
   866 0000030D 29D4                    	sub sp, dx		; reserve space for gg error info
   867                                  %endif
   868 0000030F 50                      	push ax
   869                                  %if _NUM_G_BP
   870 00000310 E88003                  	call gg_restorepoints_and_init_error_info
   871                                  %endif
   872                                  %if _BREAKPOINTS
   873 00000313 51                      	 push cx
   874 00000314 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   875 00000317 E8C903                  	call bb_restorepoints_and_init_error_info
   876 0000031A 59                      	 pop cx
   877                                  %endif
   878                                  		; Exit special mode: No longer skip cseip breakpoints.
   879 0000031B 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
   880 00000320 58                      	pop ax
   881 00000321 51                      	 push cx
   882                                  
   883                                  %if _PM
   884 00000322 E8EF06                  	call resetmode
   885                                  %endif
   886 00000325 E88700                  	call put_deferred_message_silent
   887                                  
   888 00000328 FF36[0200]              	 push word [tpg_proceed_bp + 2]
   889 0000032C FF36[0000]              	 push word [tpg_proceed_bp]
   890 00000330 8A1E[0800]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
   891 00000334 B700                    	mov bh, 0		; proceed breakpoint
   892 00000336 E8BC11                  	call display_breakpoint_failure
   893 00000339 59                      	 pop cx
   894 0000033A E927FF                  	jmp .gg_bb_cseip_fail_common
   895                                  
   896                                  
   897                                  @@:
   898 0000033D 9D                      	popf			; CF
   899                                  
   900 0000033E 7218                    	jc .after_run		; an unexpected interrupt occured -->
   901                                  
   902 00000340 E84000                  	call .after_run_restore	; restore stuff
   903 00000343 E85402                  	call gg_bb_check_hit	; expected interrupt matches our gg or bb ?
   904 00000346 7321                    	jnc .expectedinterrupt	; yes, handle expected interrupt -->
   905                                  
   906                                  
   907                                  		; Clear all special modes. Stop specialcasing cseip breakpoint.
   908 00000348 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
   911 0000034D E982FE                  	jmp gg5			; next write all points and run -->
   912                                  %endif	; _NUM_G_BP || _BREAKPOINTS
   913                                  
   914                                  .only_run:
   915                                  		; Clear all special modes. Stop specialcasing cseip breakpoint.
   916 00000350 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
   919                                  
   920 00000355 E89213                  	call run		; Now run the program.
   921                                  .after_run:
   922                                  %if _NUM_G_BP || _BREAKPOINTS
   923 00000358 E82800                  	call .after_run_restore
   924                                  
   925 0000035B E83C02                  	call gg_bb_check_hit
   926                                  .after_gg_bb_check_hit:
   927 0000035E 7309                    	jnc .expectedinterrupt
   928                                  %endif	; _NUM_G_BP || _BREAKPOINTS
   929                                  .unexpectedinterrupt:
   930                                  %if _PM
   931 00000360 E8B106                  	call resetmode
   932                                  %endif
   933 00000363 E84900                  	call put_deferred_message_silent
   934 00000366 E9670C                  	jmp unexpectedinterrupt	; print messages for unexpected breakpoint and quit.
   935                                  
   936                                  %if _NUM_G_BP || _BREAKPOINTS
   937                                  .expectedinterrupt:
   938 00000369 E86500                  	call adjust_cseip_after_breakpoint
   939                                  				; it's one of our breakpoints, adjust (e)ip
   940                                  
   941 0000036C 89C1                    	mov cx, ax		; handle_bb_* expects flags in cx
   942 0000036E 50                      	push ax
   943 0000036F 50                      	push ax			; handle_bb_* expects dword counter on stack
   944 00000370 E82509                  	call handle_bb_hit_pass_match
   945 00000373 58                      	pop ax
   946 00000374 58                      	pop ax			; discard
   947 00000375 7203E958FE              	jnc gg5			; if it was a pass non-hit or non-pass non-hit
   948                                  				;  then jump back to do a subsequent G step
   949                                  		; If jumping, the function has set up gg_first_cseip_linear
   950                                  		;  with the current CS:(E)IP so that the next step will start
   951                                  		;  out with skipping past the breakpoint(s) on that address.
   952                                  		; Note that gg_bb_check_hit returns ax = 7 if a gg point is
   953                                  		;  hit, so we always fall through to .actual_hit here.
   954                                  
   955                                  .actual_hit:
   956                                  %if _PM
   957 0000037A E89706                  	call resetmode
   958                                  %endif
   959 0000037D E82F00                  	call put_deferred_message_silent
   960                                  				; (put bb message after gg_bb_check_hit call)
   961 00000380 E95710                  	jmp dumpregs_extended_silent
   962                                  				; (handles sf_(double_)ctrl_c)
   963                                  %endif
   964                                  
   965                                  
   966                                  .after_run_restore:
   967                                  %if _NUM_G_BP || _BREAKPOINTS
   968 00000383 83EC20                   	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   969                                  				; reserve space for bb error info
   970 00000386 89E5                    	mov bp, sp		; -> behind gg error info, -> bb error info
   971                                   %if _NUM_G_BP
   972 00000388 31C9                    	xor cx, cx
   973 0000038A 8A0E[0000]              	mov cl, byte [g_bplist.used_count]
   974 0000038E 89CA                    	mov dx, cx
   975 00000390 01D2                    	add dx, dx
   976 00000392 29D4                    	sub sp, dx		; reserve space for gg error info
   977 00000394 E8FC02                  	call gg_restorepoints_and_init_error_info
   978                                  				; try restoring gg points, and fill error info
   979                                   %endif
   980                                   %if _BREAKPOINTS
   981 00000397 51                      	push cx
   982 00000398 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   983                                  				; = index above last one to restore
   984 0000039B E84503                  	call bb_restorepoints_and_init_error_info
   985                                  				; try restoring bb points, and fill error info
   986 0000039E 59                      	pop cx
   987                                   %endif
   988                                  
   989                                  %if _PM
   990 0000039F E87206                  	call resetmode
   991                                  %endif
   992 000003A2 E80A00                  	call put_deferred_message_silent
   993                                  
   994                                   %if _NUM_G_BP
   995 000003A5 E8D504                  	call gg_handlefailedrestore
   996                                  				; handle gg point restore failures
   997                                   %endif
   998                                   %if _BREAKPOINTS
   999 000003A8 E8A004                  	call bb_handlefailedrestore
  1000                                  				; handle bb point restore failures
  1001                                   %endif
  1002                                   %if _NUM_G_BP
  1003                                    %if _BREAKPOINTS
  1004 000003AB 8D6620                  	lea sp, [bp + (_NUM_B_BP + _NUM_SYM_BP) * 2]
  1005                                    %else
  1006                                  	mov sp, bp		; remove the stack frame
  1007                                    %endif
  1008                                   %else
  1009                                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1010                                   %endif
  1011                                  %endif	; _NUM_G_BP || _BREAKPOINTS
  1012 000003AE C3                      	retn
  1013                                  
  1014                                  
  1015                                  		; INP:	word [gg_deferred_message]
  1016                                  		;	word [bb_deferred_message_in_lineout_behind]
  1017                                  		; OUT:	variables reset to msg.empty_message
  1018                                  		;	messages displayed; first the gg one then the bb one
  1019                                  		; CHG:	dx
  1020                                  		; STT:	ds = es = ss
  1021                                  		;
  1022                                  		; Note:	Uses putsz_silent and putsline_silent, meaning
  1023                                  		;	 if silent mode is enabled, the messages are
  1024                                  		;	 written to the silent buffer instead of displayed.
  1025                                  put_deferred_message_silent:
  1026 000003AF BA[0000]                	mov dx, msg.empty_message
  1027 000003B2 8716[0000]              	xchg dx, word [gg_deferred_message]
  1028 000003B6 E87D0A                  	call putsz_silent
  1029 000003B9 BA[560E]                	mov dx, putsline_silent
  1030                                  
  1031                                  		; INP:	dx = puts function to call, CHG ax, bx, cx, dx, di
  1032                                  		; CHG:	dx
  1033                                  		; STT:	ds = es = ss
  1034                                  put_bb_deferred_message_calling_dx:
  1035 000003BC 57                      	push di
  1036 000003BD 31FF                    	xor di, di
  1037 000003BF 873E[0000]              	xchg di, word [bb_deferred_message_in_lineout_behind]
  1038 000003C3 85FF                    	test di, di
  1039 000003C5 7408                    	jz @F
  1040 000003C7 50                      	push ax
  1041 000003C8 53                      	push bx
  1042 000003C9 51                      	push cx
  1043 000003CA FFD2                    	call dx
  1044 000003CC 59                      	pop cx
  1045 000003CD 5B                      	pop bx
  1046 000003CE 58                      	pop ax
  1047                                  @@:
  1048 000003CF 5F                      	pop di
  1049 000003D0 C3                      	retn
  1050                                  
  1051                                  
  1052                                  		; INP:	[internalflags2] & dif2_tpg_adjusted_cseip
  1053                                  		;	[internalflags2] & dif2_tpg_do_not_adjust
  1054                                  		;	word [reg_cs]
  1055                                  		;	(d)word [reg_eip]
  1056                                  		; OUT:	If both flags clear on input,
  1057                                  		;	 set [internalflags2] & dif2_tpg_adjusted_cseip
  1058                                  		;	 cs:(e)ip adjusted by decrementing (e)ip
  1059                                  		;	 (It is only decremented by the first call to this
  1060                                  		;	  function, which sets the flag in dif2.)
  1061                                  		;	Else,
  1062                                  		;	 do nothing
  1063                                  		; CHG:	bx
  1064                                  		; STT:	ds = ss = debugger data selector
  1065                                  adjust_cseip_after_breakpoint:
  1066 000003D1 F606[0100]06            	testopt [internalflags2], 		dif2_tpg_adjusted_cseip | dif2_tpg_do_not_adjust
  1068 000003D6 7513                    	jnz .retn
  1069 000003D8 800E[0100]02            	setopt [internalflags2], dif2_tpg_adjusted_cseip
  1070 000003DD 8B1E[0000]              _386_PM	mov bx, word [reg_cs]
  1071 000003E1 E8(0000)                _386_PM	call resetmode_and_test_d_b_bit
  1072 000003E4 7401                    _386_PM	jz .16			; 16-bit cs -->
  1073 000003E6 66                      _386_PM	o32			; dec dword [reg_eip]
  1074                                  .16:
  1075 000003E7 FF0E[0000]              	dec word [reg_eip]	; re-execute (restored) opcode one byte in front of this
  1076                                  .retn:
  1077 000003EB C3                      	retn
  1078                                  
  1079                                  
  1080                                  %ifn _BREAKPOINTS
  1081                                  bb_check_hit:
  1082                                  	xor ax, ax
  1083                                  	stc
  1084                                  	retn
  1085                                  %else
  1086                                  		; INP:	word [run_int]
  1087                                  		;	word [reg_cs]
  1088                                  		;	(d)word [reg_eip]
  1089                                  		;	bb breakpoints
  1090                                  		; OUT:	NC if a breakpoint was hit,
  1091                                  		;	 (e)ip must be decremented by one
  1092                                  		;	 word [bb_deferred_message_in_lineout_behind] set
  1093                                  		;	  and line_out written if bb point matched
  1094                                  		;	 (The bb point's index is already written to this msg.)
  1095                                  		;	 ax & 1 set if non-pass match (actual hit),
  1096                                  		;	  else ax & 2 set if pass match	(consider as hit first,
  1097                                  		;		but dump registers next (not to silent buffer)
  1098                                  		;		and then continue execution)
  1099                                  		;	  else ax & 4 always set, indicates any match
  1100                                  		;		(including matches that should merely continue)
  1101                                  		;	 all pass points' counters stepped
  1102                                  		;	CY if no breakpoint was hit,
  1103                                  		;	 ax = 0
  1104                                  		; CHG:	all
  1105                                  		; STT:	es = ds = ss
  1106                                  bb_check_hit:
  1107                                  	lframe near
  1108 000003EC 5589E5                  	lenter
  1109 000003EF 31C0                    	xor ax, ax
  1110                                  	lequ 1,		flag_trigger
  1111                                  	lequ 2,		flag_pass
  1112                                  	lequ 4,		flag_match
  1113                                  	lvar word,	flags
  1114 000003F1 50                      	 push ax
  1115                                  
  1116                                  		; Finish up. Check if it was one of _our_ breakpoints.
  1117 000003F2 813E[0000][0000]        	cmp word [run_int], int3msg
  1118 000003F8 7505                    	jne @F			; if not interrupt 03h -->
  1119                                  
  1120                                  			; Get previous cs:eip (where breakpoint was executed if any at all).
  1121 000003FA E89805                  	call get_cseip_of_possible_breakpoint
  1122                                  				; dx:ax = linear address of previous cs:eip
  1123                                  				; bx = reg_cs
  1124 000003FD EB16                    	jmp .check
  1125                                  
  1126                                  @@:
  1127                                  		; For T/TP/P: if trace interrupt fired just while
  1128                                  		;  pointing at a bb point, do match.
  1129 000003FF 813E[0000][0000]        	cmp word [run_int], int1msg
  1130 00000405 7403E95901              	jne .gg9
  1131                                  
  1132 0000040A 800E[0100]04            	setopt [internalflags2], dif2_tpg_do_not_adjust
  1133                                  				; remember that we should not adjust
  1134 0000040F 66                      	_386_PM_o32
  1135 00000410 31C9                    	xor cx, cx
  1136 00000412 E8A504                  	call get_cseip_ecx_linear
  1137                                  				; get linear of this cs:(e)ip
  1138                                  .check:
  1139 00000415 7303E94901              	jc .gg9
  1140                                  
  1141                                  		; Store the matched address (if any) here in case of non-hit
  1142                                  		;  match. (Ie, non-hit pass match or non-hit non-pass match.)
  1143 0000041A A3[0000]                	mov word [gg_next_cseip_linear], ax
  1144 0000041D 8916[0200]              	mov word [gg_next_cseip_linear + 2], dx
  1145                                  
  1146 00000421 87DA                    	xchg bx, dx
  1147 00000423 91                      	xchg cx, ax		; bx:cx = linear address of previous cs:eip
  1148 00000424 31C0                    	xor ax, ax
  1149                                  .loop:
  1150 00000426 53                      	push bx
  1151 00000427 50                      	push ax
  1152 00000428 E8(0000)                	call calcpointbit	; bx = index, ah = value
  1153 0000042B 84A7[0000]              	test byte [b_bplist.used_mask+bx], ah
  1154                                  				; (NC)
  1155 0000042F 7503E91D01              	jz .next
  1156 00000434 84A7[0000]              	test byte [b_bplist.disabled_mask+bx], ah
  1157                                  				; (NC)
  1158 00000438 7403E91401              	jnz .next
  1159 0000043D 58                      	pop ax
  1160 0000043E 5B                      	pop bx
  1161 0000043F 53                      	push bx
  1162 00000440 50                      	push ax
  1163 00000441 89C6                    	mov si, ax
  1164 00000443 01F6                    	add si, si
  1165 00000445 01F6                    	add si, si
  1166                                  %if BPSIZE == 4
  1167                                  %elif BPSIZE == 5
  1168                                  	add si, ax
  1169                                  %elif BPSIZE == 6
  1170                                  	add si, ax		; * 5
  1171                                  	add si, ax		; * 6
  1172                                  %elif BPSIZE == 9
  1173 00000447 01F6                    	add si, si		; * 8
  1174 00000449 01C6                    	add si, ax		; * 9
  1175                                  %else
  1176                                   %error Unexpected breakpoint size
  1177                                  %endif
  1178 0000044B 81C6[0000]              	add si, b_bplist.bp	; -> point
  1179                                  
  1180 0000044F E84301                  	call gg_bb_lods_bp_linear
  1181                                  
  1182 00000452 E89403                  	call gg_bb_check_is_first
  1183 00000455 7203E9F700              	jnc .next
  1184                                  
  1185 0000045A 39C8                    	cmp ax, cx
  1186 0000045C 7403E9F000              	jne .next
  1187 00000461 39DA                    	cmp dx, bx
  1188 00000463 7403E9E900              	jne .next
  1189                                  
  1190                                  .hit:
  1191 00000468 58                      	 pop ax
  1192 00000469 50                      	 push ax
  1193                                  
  1194 0000046A 804EFE04                	or byte [bp + ?flags], ?flag_match
  1195                                  
  1196                                  %if _SYMBOLIC
  1197                                  	cmp ax, _NUM_B_BP	; is it a symbol breakpoint ?
  1198                                  	jb @F			; no -->
  1199                                  
  1200                                  		; skip WHEN and counter handling for symbol breakpoints
  1201                                  	test byte [bp + ?flags], ?flag_trigger
  1202                                  				; triggered yet ?
  1203                                  	jz .setup_trigger	; no, trigger now -->
  1204                                  	jmp .next		; yes, ignore -->
  1205                                  
  1206                                  @@:
  1207                                  %endif
  1208 0000046E 89C7                    	mov di, ax
  1209 00000470 01FF                    	add di, di
  1210                                  
  1211 00000472 8BB5[0000]              	mov si, [b_bplist.when + di]
  1212                                  				; si -> condition
  1213 00000476 85F6                    	test si, si		; any ?
  1214 00000478 7422                    	jz @F			; no -->
  1215                                  %if _PM
  1216 0000047A E89705                  	call resetmode
  1217                                  %endif
  1218 0000047D FF36[0000]              	push word [rc]
  1219 00000481 8F06[0000]              	pop word [priorrc]
  1220 00000485 AC                      	lodsb
  1221 00000486 E8(0000)[0000]          	nearcall getexpression	; parse stored expression
  1222 0000048B E8(0000)                	call chkeol
  1223 0000048E E8(0000)[0000]          	nearcall toboolean	; get boolean
  1224 00000493 85D2                    	test dx, dx		; true ?
  1225 00000495 7503E9B700              	jz .next		; no, skip -->
  1226 0000049A 58                      	 pop ax
  1227 0000049B 50                      	 push ax
  1228                                  @@:
  1229                                  
  1230 0000049C 8D9D[0000]              	lea bx, [b_bplist.counter + di]
  1231                                  				; word [bx] = this matched point's counter
  1232                                  
  1233 000004A0 F646FE03                	test byte [bp + ?flags], ?flag_trigger | ?flag_pass
  1234 000004A4 7413                    	jz @F			; none set yet ? -->
  1235 000004A6 E8C100                  	call step_pass_counter	; step counter even if already matched
  1236 000004A9 7203E9A300              	jnc .next		; (either is already set, so additional
  1237                                  				;  setting of ?flag_pass is skipped)
  1238 000004AE F646FE01                	test byte [bp + ?flags], ?flag_trigger
  1239 000004B2 7403E99A00              	jnz .next		; (trigger is already set, so skip triggering)
  1240 000004B7 EB05                    	jmp .setup_trigger	; triggered (after previous pass match)
  1241                                  
  1242                                  @@:
  1243 000004B9 E8AE00                  	call step_pass_counter	; step counter of matched point, no flag yet
  1244 000004BC 7340                    	jnc .check_pass		; not triggered, check for pass match -->
  1245                                  
  1246                                  .setup_trigger:
  1247                                  		; Trigger! (And the first detected triggering point.)
  1248 000004BE 804EFE01                	or byte [bp + ?flags], ?flag_trigger
  1249                                  
  1250 000004C2 51                      	push cx
  1251 000004C3 BF[0000]                	mov di, line_out
  1252 000004C6 BE[0000]                	mov si, msg.bb_hit.1
  1253                                  %if _SYMBOLIC
  1254                                  	cmp ax, _NUM_B_BP
  1255                                  	jb @F
  1256                                  	mov si, msg.bb_sym_hit.1
  1257                                  @@:
  1258                                  %endif
  1259 000004C9 E8C100                  	call copy_single_counted_string
  1260                                  		; (If _SYMBOLIC=0) Now si -> msg.bb_hit.2.nocounter
  1261                                  		; (If _SYMBOLIC=1) Now si -> msg.bb_hit.2.nocounter
  1262                                  		;		or si -> msg.bb_sym_hit.2.nocounter
  1263                                  
  1264                                  
  1265 000004CC 89C2                    	mov dx, ax
  1266                                  %if _SYMBOLIC
  1267                                  	cmp ax, _NUM_B_BP
  1268                                  	jb @F
  1269                                  	sub ax, _NUM_B_BP
  1270                                  	call hexbyte		; store index of this point
  1271                                  	jmp @FF			; skip counter dump -->
  1272                                  
  1273                                  @@:
  1274                                  %endif
  1275                                  		; Store breakpoint index in message.
  1276 000004CE E8(0000)                	call hexbyte		; store index of this point
  1277                                  
  1278                                  		; Get counter of this breakpoint.
  1279 000004D1 8B07                    	mov ax, word [bx]
  1280                                  
  1281                                  		; Is it equal to default ?
  1282 000004D3 3D0080                  	cmp ax, 8000h
  1283 000004D6 7409                    	je @F			; yes, skip -->
  1284                                  
  1285 000004D8 BE[0000]                	mov si, msg.bb_hit.2.counter
  1286 000004DB E8AF00                  	call copy_single_counted_string
  1287                                  		; Now si -> msg.bb_hit.3.counter.no_id
  1288                                  
  1289                                  		; Store counter in message.
  1290 000004DE E8(0000)                	call hexword
  1291                                  
  1292                                  @@:
  1293 000004E1 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  1294 000004E6 7407                    	jz @F
  1295 000004E8 F606[0200]08            	testopt [options], gg_bb_hit_no_repeat
  1296 000004ED EB05                    	jmp @FF
  1297                                  @@:
  1298 000004EF F606[0200]10            	testopt [options], tp_bb_hit_no_repeat
  1299                                  @@:
  1300 000004F4 7406                    	jz @F
  1301 000004F6 C706[0000][0000]        	mov word [lastcmd], dmycmd
  1302                                  @@:
  1303 000004FC EB1D                    	jmp .trigger_common
  1304                                  
  1305                                  
  1306                                  .check_pass:
  1307 000004FE 7451                    	jz .next		; no pass match ? -->
  1308                                  
  1309 00000500 804EFE02                	or byte [bp + ?flags], ?flag_pass
  1310                                  
  1311 00000504 51                      	push cx
  1312 00000505 BF[0000]                	mov di, line_out
  1313 00000508 BE[0000]                	mov si, msg.bb_pass.1
  1314 0000050B E87F00                  	call copy_single_counted_string
  1315                                  		; Now si -> msg.bb_pass.2
  1316                                  
  1317 0000050E 89C2                    	mov dx, ax
  1318                                  		; Store breakpoint index in message.
  1319 00000510 E8(0000)                	call hexbyte		; store index of this point
  1320                                  
  1321 00000513 E87700                  	call copy_single_counted_string
  1322                                  		; Now si -> msg.bb_pass.3.no_id
  1323                                  
  1324                                  		; Get counter of this breakpoint.
  1325 00000516 8B07                    	mov ax, word [bx]
  1326                                  		; Store counter in message.
  1327 00000518 E8(0000)                	call hexword
  1328                                  
  1329                                  .trigger_common:
  1330 0000051B 53                      	push bx
  1331                                  %if _SYMBOLIC
  1332                                  	cmp dx, _NUM_B_BP	; symbol breakpoint ?
  1333                                  	jae @F			; yes, no ID -->
  1334                                  %endif
  1335 0000051C BBFFFF                  	mov bx, -1
  1336 0000051F E8(0000)                	call get_set_id_offset_length
  1337 00000522 F6C7FC                  	test bh, 63 << 2	; length nonzero ?
  1338 00000525 7421                    	jz @F			; no -->
  1339                                  
  1340                                  		; The maximum length of a short ID is based on
  1341                                  		;  how much space there is after the longest message
  1342                                  		;  ("Passed ..., counter=XXXX") assuming 80 columns.
  1343 00000527 BE[0000]                	mov si, msg.bb_hitpass_id.short
  1344 0000052A 80FF74                  	cmp bh, 29 << 2		; long ?
  1345 0000052D 7203                    	jb .trigger_short_id
  1346                                  		; This jump MUST be a jb, not jbe. The jbe
  1347                                  		;  would not match ZR for words where the
  1348                                  		;  idbuffer offset is a nonzero value.
  1349 0000052F BE[0000]                	mov si, msg.bb_hitpass_id.long
  1350                                  .trigger_short_id:
  1351                                  
  1352 00000532 E85800                  	call copy_single_counted_string
  1353 00000535 88F9                    	mov cl, bh
  1354 00000537 D0E9                    	shr cl, 1
  1355 00000539 D0E9                    	shr cl, 1		; cx = length
  1356 0000053B 81E3FF03                	and bx, 1023		; bx = offset
  1357 0000053F 8DB7[0000]              	lea si, [b_bplist.idbuffer + bx]
  1358 00000543 F3A4                    	rep movsb
  1359                                  
  1360 00000545 BE[0000]                	mov si, msg.bb_hitpass_id.after
  1361                                  
  1362                                  @@:
  1363 00000548 5B                      	pop bx
  1364 00000549 E84100                  	call copy_single_counted_string
  1365                                  
  1366 0000054C 893E[0000]              	mov word [bb_deferred_message_in_lineout_behind], di
  1367 00000550 59                      	pop cx
  1368                                  
  1369                                  .next:
  1370 00000551 58                      	pop ax
  1371 00000552 5B                      	pop bx
  1372                                  
  1373 00000553 40                      	inc ax
  1374 00000554 83F810                  	cmp ax, _NUM_B_BP + _NUM_SYM_BP
  1375 00000557 7303E9CAFE              	jb .loop
  1376                                  
  1377 0000055C 8B46FE                  	mov ax, word [bp + ?flags]
  1378 0000055F A807                    	test al, ?flag_pass | ?flag_trigger | ?flag_match
  1379 00000561 7503                    	jnz .return		; (NC)
  1380                                  
  1381                                  .gg9:
  1382 00000563 31C0                    	xor ax, ax
  1383 00000565 F9                      	stc
  1384                                  .return:
  1385 00000566 89EC5D                  	lleave
  1386 00000569 C3                      	retn
  1387                                  
  1388                                  
  1389                                  		; INP:	word [bx] = pass counter of this breakpoint
  1390                                  		; OUT:	NC if to proceed (no trigger),
  1391                                  		;	 ZR if no pass message display
  1392                                  		;	 NZ if pass message display
  1393                                  		;	CY if to trigger
  1394                                  step_pass_counter:
  1395 0000056A F707FF3F                	test word [bx], 3FFFh		; is it already at a terminal state ?
  1396 0000056E 740A                    	jz .no_decrement		; yes, do not further decrement -->
  1397 00000570 FF0F                    	dec word [bx]			; decrement (to 0/4000h/8000h/C000h)
  1398 00000572 7417                    	jz .trigger			; case for decrementing 1 to 0 -->
  1399 00000574 813F0040                	cmp word [bx], 4000h
  1400 00000578 7411                    	je .trigger			; case for decrementing 4001h to 4000h
  1401                                  .no_decrement:
  1402 0000057A 813F0080                	cmp word [bx], 8000h		; decrement resulted in 8000h
  1403 0000057E 740B                    	je .trigger			;  or was already in that state? -->
  1404 00000580 813F00C0                	cmp word [bx], 0_C000h
  1405 00000584 7405                    	je .trigger			; or C000h -->
  1406                                  .proceed:
  1407 00000586 F6470140                	test byte [bx + 1], 40h		; (NC) ZR if no pass message
  1408 0000058A C3                      	retn
  1409                                  
  1410                                  .trigger:
  1411 0000058B F9                      	stc
  1412 0000058C C3                      	retn
  1413                                  %endif
  1414                                  %endif	; !_LOADER
  1415                                  
  1416                                  
  1417                                  		; INP:	byte [ds:si] = length of source string
  1418                                  		;	ds:si + 1 -> source string
  1419                                  		;	es:di -> destination buffer
  1420                                  		; OUT:	cx = 0
  1421                                  		;	ZR, NC
  1422                                  		;	ds:si -> after source string
  1423                                  		;	es:di -> after written string
  1424                                  		; CHG:	-
  1425                                  		; STT:	UP
  1426                                  copy_single_counted_string: section_of_function
  1427 0000058D 91                      	xchg ax, cx
  1428 0000058E 31C0                    	xor ax, ax
  1429 00000590 AC                      	lodsb
  1430 00000591 91                      	xchg ax, cx
  1431 00000592 F3A4                    	rep movsb
  1432 00000594 C3                      	retn
  1433                                  
  1434                                  
  1435                                  %if !_LOADER
  1436                                  		; INP:	si -> linear address of breakpoint
  1437                                  		;	 (32 bits if _PM, else 24 bits)
  1438                                  		; OUT:	dx:ax = linear address of breakpoint
  1439                                  		;	si -> behind linear address
  1440                                  gg_bb_lods_bp_linear:
  1441 00000595 AD                      	lodsw
  1442 00000596 92                      	xchg ax, dx
  1443                                  %if _PM
  1444 00000597 AD                      	lodsw
  1445                                  %else
  1446                                  	xor ax, ax
  1447                                  	lodsb
  1448                                  %endif
  1449 00000598 92                      	xchg ax, dx
  1450 00000599 C3                      	retn
  1451                                  
  1452                                  
  1453                                  		; INP:	word [run_int]
  1454                                  		;	word [reg_cs]
  1455                                  		;	(d)word [reg_eip]
  1456                                  		;	gg/bb breakpoints
  1457                                  		; OUT:	NC if a breakpoint was hit,
  1458                                  		;	 (e)ip must be decremented by one
  1459                                  		;	 word [bb_deferred_message_in_lineout_behind] set
  1460                                  		;	  and line_out written if bb point matched
  1461                                  		;	 (The bb point's index is already written to this msg.)
  1462                                  		;	 ax = 7 if non-bb match, else
  1463                                  		;	 ax & 1 set if non-pass match (actual hit),
  1464                                  		;	  else ax & 2 set if pass match (consider as hit first,
  1465                                  		;		but dump registers next (not to silent buffer)
  1466                                  		;		and then continue execution)
  1467                                  		;	  else ax & 4 always set, indicates any match
  1468                                  		;		(including matches that should merely continue)
  1469                                  		;	 all pass points' counters stepped
  1470                                  		;	CY if no breakpoint was hit,
  1471                                  		;	 ax = 0
  1472                                  		; CHG:	all
  1473                                  		; STT:	es = ds = ss
  1474                                  gg_bb_check_hit:
  1475 0000059A E84FFE                  	call bb_check_hit
  1476 0000059D 720D                    	jc .gg_check_hit
  1477                                  
  1478 0000059F A801                    	test al, 1		; actual bb hit ?
  1479 000005A1 7507                    	jnz .ret_NC		; yes, return as hit
  1480                                  
  1481 000005A3 50                      	push ax			; bb is pass match or any other match,
  1482 000005A4 E80500                  	call gg_check_hit	;  is gg a match ?
  1483 000005A7 58                      	pop ax
  1484 000005A8 732D                    	jnc gg_check_hit.hit	; yes --> (set NC, ax = 7)
  1485                                  
  1486                                  		; Here, we return the flags 2 (set if pass match) and
  1487                                  		; 4 (always set, indicating any match).
  1488                                  
  1489                                  .ret_NC:
  1490 000005AA F8                      	clc
  1491 000005AB C3                      	retn
  1492                                  
  1493                                  .gg_check_hit:
  1494                                  	; (fall through)
  1495                                  
  1496                                  %ifn _NUM_G_BP
  1497                                  gg_check_hit:
  1498                                  	stc
  1499                                  	retn
  1500                                  %else
  1501                                  		; INP:	word [run_int]
  1502                                  		;	word [reg_cs]
  1503                                  		;	(d)word [reg_eip]
  1504                                  		;	bb breakpoints
  1505                                  		; OUT:	NC if a breakpoint was hit,
  1506                                  		;	 (e)ip must be decremented by one
  1507                                  		;	 ax = 7
  1508                                  		;	CY if no breakpoint was hit,
  1509                                  		;	 ax = 0
  1510                                  		; CHG:	all
  1511                                  		; STT:	es = ds = ss
  1512                                  gg_check_hit:
  1513                                  		; Finish up. Check if it was one of _our_ breakpoints.
  1514 000005AC 813E[0000][0000]        	cmp word [run_int], int3msg
  1515 000005B2 752D                    	jne .gg9		; if not interrupt 03h -->
  1516                                  
  1517                                  			; Get previous cs:eip (where breakpoint was executed if any at all).
  1518 000005B4 E8DE03                  	call get_cseip_of_possible_breakpoint
  1519                                  				; dx:ax = linear address of previous cs:eip
  1520 000005B7 7228                    	jc .gg9
  1521 000005B9 BE[0000]                	mov si, g_bplist.bp
  1522 000005BC 31C9                    	xor cx, cx
  1523 000005BE 8A4CFF                  	mov cl, byte [si-1]	; number of saved breakpoints
  1524 000005C1 E31E                    	jcxz .gg9		; none, so always unexpected -->
  1525                                  
  1526 000005C3 89C7                    	mov di, ax
  1527 000005C5 89D3                    	mov bx, dx		; bx:di = linear address of previous cs:(e)ip
  1528                                  
  1529                                  .loop_gg6:
  1530 000005C7 E8CBFF                  	call gg_bb_lods_bp_linear
  1531                                  
  1532 000005CA E81C02                  	call gg_bb_check_is_first
  1533 000005CD 730D                    	jnc .next
  1534                                  
  1535 000005CF 39DA                    	cmp dx, bx
  1536 000005D1 7509                    	jne .next
  1537 000005D3 39F8                    	cmp ax, di
  1538 000005D5 7505                    	jne .next
  1539                                  
  1540                                  .hit:
  1541 000005D7 B80700                  	mov ax, 7
  1542 000005DA F8                      	clc
  1543 000005DB C3                      	retn
  1544                                  
  1545                                  .next:
  1546                                  
  1547                                  %if BPSIZE == 4 || BPSIZE == 5
  1548                                  	inc si			; skip saved (actually CCh) byte
  1549                                  %elif BPSIZE == 6
  1550                                  	add si, 3		; skip word offset and byte content
  1551                                  %elif BPSIZE == 9
  1552 000005DC 83C605                  	add si, 5		; skip dword offset and byte content
  1553                                  %endif
  1554                                  				; BPSIZE implied
  1555 000005DF E2E6                    	loop .loop_gg6		; try next if there's any
  1556                                  
  1557                                  .gg9:
  1558 000005E1 31C0                    	xor ax, ax
  1559 000005E3 F9                      	stc
  1560 000005E4 C3                      	retn
  1561                                  %endif
  1562                                  
  1563                                  
  1564                                  %if _DELAY_BEFORE_BP
  1565                                  delay_before_bp:
  1566 000005E5 F606[0300]04            	testopt [options3], opt3_delay_before_bp
  1567 000005EA 7428                    	jz .ret
  1568 000005EC F606[0200]80            	testopt [internalflags3], dif3_delayed
  1569 000005F1 7521                    	jnz .ret
  1570 000005F3 800E[0200]80            	setopt [internalflags3], dif3_delayed
  1571 000005F8 06                      	push es
  1572 000005F9 57                      	push di
  1573 000005FA 50                      	push ax
  1574 000005FB BF4000                  	mov di, 40h		; dual mode segment/selector
  1575 000005FE 8EC7                    	mov es, di
  1576 00000600 268B3E6C00              	mov di, word [es:6Ch]
  1577                                  @@:
  1578 00000605 263B3E6C00              	cmp di, word [es:6Ch]
  1579 0000060A 7505                    	jne @F
  1580 0000060C E8(0000)                	call idle
  1581 0000060F EBF4                    	jmp @B
  1582                                  @@:
  1583 00000611 58                      	pop ax
  1584 00000612 5F                      	pop di
  1585 00000613 07                      	pop es
  1586                                  .ret:
  1587 00000614 C3                      	retn
  1588                                  %endif
  1589                                  
  1590                                  
  1591                                  %if _BREAKPOINTS
  1592                                  bb_writepoints_init_reset:
  1593 00000615 BF[0000]                	mov di, b_bplist.bp
  1594 00000618 B0CC                    	mov al, 0CCh
  1595 0000061A B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  1596                                  .loop:
  1597 0000061D 83C708                  	add di, BPSIZE - 1
  1598 00000620 AA                      	stosb
  1599 00000621 E2FA                    	loop .loop
  1600                                  
  1601                                  		; This is called first by gg before writing any of the
  1602                                  		;  gg points. So, if it fails, it only needs to restore
  1603                                  		;  its own points, not any of the gg points.
  1604                                  		; This is also called deep down in run_with_bb when called
  1605                                  		;  from tt or pp. In this case, there may be a proceed
  1606                                  		;  breakpoint already written. On failure, after having
  1607                                  		;  restored all yet-written bb points, this proceed
  1608                                  		;  breakpoint is restored too.
  1609                                  		; Symbolic branch: This initialises symbol breakpoints.
  1610                                  		;
  1611                                  		; INP:	bb breakpoints
  1612                                  		;	tpg_proceed_bp
  1613                                  		; OUT:	does not return if an error occurred,
  1614                                  		;	 instead jumps to cmd3
  1615                                  		; STT:	might return modeswitched
  1616                                  bb_writepoints_init:
  1617                                  %if _SYMBOLIC
  1618                                  	nearcall zz_detect_xms	; re-detect XMS if used after run
  1619                                  
  1620                                  	mov dx, word [sym_storage.main.bb.first]
  1621                                  	mov bx, b_bplist.bp + _NUM_B_BP * BPSIZE
  1622                                  	mov cx, _NUM_B_BP
  1623                                  	jmp .sym_condition
  1624                                  
  1625                                  .sym_loop:
  1626                                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  1627                                  	jb .sym_enough
  1628                                  	mov dx, msg.bb_sym_too_many
  1629                                  .sym_error_putsz:
  1630                                  	call putsz_error
  1631                                  	mov cx, (_NUM_B_BP + _NUM_SYM_BP)
  1632                                  	xor ax, ax
  1633                                  @@:
  1634                                  	push ax
  1635                                  	loop @B			; dummy bb error info
  1636                                  	mov bp, sp
  1637                                  	dec cx			; no bb write/restore failure
  1638                                  	push cx
  1639                                  	push cx
  1640                                  	jmp .sym_error_done	; handle error (including pp restore) -->
  1641                                  
  1642                                  .sym_enough:
  1643                                  	 push dx
  1644                                  	 push ax
  1645                                  	dualcall getfarpointer.main
  1646                                  	 pop di
  1647                                  	 pop es
  1648                                  
  1649                                  	mov ax, word [es:di + smLinear]
  1650                                  	mov word [bx], ax	; store low word of linear
  1651                                  	inc bx
  1652                                  	inc bx
  1653                                  	mov ax, word [es:di + smLinear + 2]
  1654                                  %if BPSIZE == 5 || BPSIZE == 9
  1655                                  	mov word [bx], ax	; store high word of linear
  1656                                  	inc bx
  1657                                  	inc bx
  1658                                  %else
  1659                                  	mov byte [bx], al	; store high byte of linear
  1660                                  	inc bx
  1661                                  	mov dx, msg.bb_sym_beyond_linear
  1662                                  	test ah, ah
  1663                                  	jnz .sym_error_putsz
  1664                                  %endif
  1665                                  %if BPSIZE == 6 || BPSIZE == 9
  1666                                  	mov ax, word [es:di + smOffset]
  1667                                  	mov word [bx], ax	; store low word of offset
  1668                                  	inc bx
  1669                                  	inc bx
  1670                                  	mov ax, word [es:di + smOffset + 2]
  1671                                   %if BPSIZE == 9
  1672                                  	mov word [bx], ax	; store high word of offset
  1673                                  	inc bx
  1674                                  	inc bx
  1675                                   %else
  1676                                  	mov dx, msg.bb_sym_beyond_offset
  1677                                  	test ax, ax
  1678                                  	jnz .sym_error_putsz
  1679                                   %endif
  1680                                  %endif
  1681                                  	inc bx			; skip content byte
  1682                                  	mov ax, cx
  1683                                  	push bx
  1684                                  	call calcpointbit
  1685                                  	or byte [b_bplist.used_mask + bx], ah
  1686                                  	pop bx
  1687                                  	inc cx
  1688                                  	mov dx, word [es:di + smSpecialNext]
  1689                                  
  1690                                  .sym_condition:
  1691                                  	cmp dx, -1
  1692                                  	jne .sym_loop
  1693                                  
  1694                                  	jmp @FF
  1695                                  @@:
  1696                                  	mov ax, cx
  1697                                  	call calcpointbit
  1698                                  	not ah
  1699                                  	and byte [b_bplist.used_mask + bx], ah
  1700                                  	inc cx
  1701                                  @@:
  1702                                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  1703                                  	jb @BB
  1704                                  %endif
  1705                                  
  1706 00000623 E8D500                  	call bb_writepoints
  1707 00000626 735B                    	jnc .retn
  1708                                  
  1709 00000628 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1710                                  				; reserve space for bb error info
  1711 0000062B 89E5                    	mov bp, sp
  1712                                  		; cx = index of failed point
  1713                                  		;    = index above last one to restore
  1714                                  		; ax = error info of failed point
  1715 0000062D 50                      	push ax
  1716 0000062E 51                      	push cx
  1717 0000062F E8B100                  	call bb_restorepoints_and_init_error_info
  1718                                  .sym_error_done:
  1719                                  
  1720                                  bb_restorepoints_exit: equ $
  1721                                  		; If this is not gg and T/P wrote a proceed breakpoint,
  1722                                  		;  restore it here (after having restored bb points).
  1723 00000632 E8570E                  	call proceed_writepoint_restore
  1724                                  		; This call might return modeswitched.
  1725 00000635 BB0000                  	mov bx, 0		; (preserve CF)
  1726 00000638 7305                    	jnc @F
  1727 0000063A 80CC80                  	or ah, 80h		; mark error during restoration
  1728 0000063D 89C3                    	mov bx, ax		; bx & 80h set: error restoring pp
  1729                                  @@:
  1730                                  
  1731 0000063F 59                      	pop cx
  1732 00000640 58                      	pop ax			; error info + index of failed point
  1733                                  
  1734 00000641 89CE                    	mov si, cx
  1735 00000643 01F6                    	add si, si
  1736 00000645 01F6                    	add si, si		; * 4
  1737                                  %if BPSIZE == 4
  1738                                  %elif BPSIZE == 5
  1739                                  	add si, cx		; * 5
  1740                                  %elif BPSIZE == 6
  1741                                  	add si, cx		; * 5
  1742                                  	add si, cx		; * 6
  1743                                  %elif BPSIZE == 9
  1744 00000647 01F6                    	add si, si		; * 8
  1745 00000649 01CE                    	add si, cx		; * 9
  1746                                  %else
  1747                                   %error Unexpected breakpoint size
  1748                                  %endif
  1749 0000064B 81C6[0000]              	add si, b_bplist.bp	; -> point
  1750                                  
  1751 0000064F 53                      	push bx
  1752                                  
  1753 00000650 E85CFD                  	call put_deferred_message_silent
  1754                                  				; CHG: dx
  1755                                  
  1756 00000653 83F9FF                  	cmp cx, -1
  1757 00000656 740B                    	je @F
  1758                                  
  1759                                  		; si-> point
  1760                                  		; ax = info (ah = reason, al = new value if reason 3)
  1761                                  		; cx = 0-based index of initially failed point
  1762 00000658 FF7402                  	 push word [si + 2]
  1763 0000065B FF34                    	 push word [si]		; stack: linear address
  1764 0000065D BB0040                  	mov bx, 4000h		; bh = 40h (bb),
  1765                                  				;  bl = what we tried to restore (n/a)
  1766 00000660 E8920E                  	call display_breakpoint_failure
  1767                                  		; This function calls resetmode.
  1768                                  
  1769                                  @@:
  1770 00000663 E8E501                  	call bb_handlefailedrestore
  1771                                  		; This function calls resetmode.
  1772                                  
  1773 00000666 58                      	pop ax
  1774 00000667 F6C480                  	test ah, 80h		; pp failed to restore ?
  1775 0000066A 7411                    	jz @F
  1776                                  
  1777 0000066C FF36[0200]              	 push word [tpg_proceed_bp + 2]
  1778 00000670 FF36[0000]              	 push word [tpg_proceed_bp]
  1779 00000674 8A1E[0800]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
  1780 00000678 B700                    	mov bh, 0		; proceed breakpoint
  1781 0000067A E8780E                  	call display_breakpoint_failure
  1782                                  @@:
  1783 0000067D 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1784                                  				; discard bb error info
  1785 00000680 E9(0000)                	jmp cmd3
  1786                                  
  1787                                  .retn:
  1788 00000683 C3                      	retn
  1789                                  %endif
  1790                                  
  1791                                  
  1792                                  %if _NUM_G_BP
  1793                                  		; INP:	ss:bp -> behind gg error info space
  1794                                  		;	cx = number of error info words on stack
  1795                                  		; OUT:	error info space initialised to all zeros
  1796                                  		; CHG:	ax, di, es
  1797                                  		; STT:	sets es to ss
  1798                                  gg_restorepoints_init_error_info:
  1799 00000684 16                      	push ss
  1800 00000685 07                      	pop es
  1801 00000686 89EF                    	mov di, bp		; es:di -> behind error info
  1802 00000688 51                      	push cx
  1803 00000689 4F                      	dec di
  1804 0000068A 4F                      	dec di
  1805 0000068B 31C0                    	xor ax, ax
  1806 0000068D FD                      	std			; _AMD_ERRATUM_109_WORKAROUND does not apply
  1807 0000068E F3AB                    	rep stosw		; initialize error info
  1808 00000690 FC                      	cld
  1809 00000691 59                      	pop cx
  1810 00000692 C3                      	retn
  1811                                  
  1812                                  
  1813                                  gg_restorepoints_and_init_error_info:
  1814 00000693 E8EEFF                  	call gg_restorepoints_init_error_info
  1815                                  
  1816                                  		; Restore gg breakpoints.
  1817                                  		; On errors remember failures but restore all remaining anyway.
  1818                                  		;
  1819                                  		; INP:	cx = number of breakpoints to restore (<= 255),
  1820                                  		;		assumed at beginning of g_bplist.bp
  1821                                  		;	ss:bp -> behind cx words for error info
  1822                                  		; OUT:	NC if all points restored successfully
  1823                                  		;	CY if at least one point couldn't be restored,
  1824                                  		;	 error info filled, high byte:
  1825                                  		;	  reason =	0 = no error (this point didn't fail),
  1826                                  		;			1 = couldn't write,
  1827                                  		;			2 = unreachable,
  1828                                  		;			3 = overwritten),
  1829                                  		;	  low byte: new byte value (if reason 3)
  1830                                  		; CHG:	ax, bx, (e)dx, si, di, es
  1831                                  		; STT:	sets es to ss
  1832                                  		;	might return modeswitched
  1833                                  		;
  1834                                  		; Note:	The points are restored in reverse, from the last back
  1835                                  		;	 to the front. The first point is handled last.
  1836                                  gg_restorepoints:
  1837 00000696 89CE                    	mov si, cx
  1838 00000698 01F6                    	add si, si
  1839 0000069A 01F6                    	add si, si		; * 4
  1840                                  %if BPSIZE == 4
  1841                                  %elif BPSIZE == 5
  1842                                  	add si, cx		; * 5
  1843                                  %elif BPSIZE == 6
  1844                                  	add si, cx		; * 5
  1845                                  	add si, cx		; * 6
  1846                                  %elif BPSIZE == 9
  1847 0000069C 01F6                    	add si, si		; * 8
  1848 0000069E 01CE                    	add si, cx		; * 9
  1849                                  %else
  1850                                   %error Unexpected breakpoint size
  1851                                  %endif
  1852 000006A0 81C6[F7FF]              	add si, g_bplist.bp - BPSIZE	; -> last point in list (first to restore)
  1853                                  
  1854 000006A4 F8                      	clc			; assume success
  1855 000006A5 51                      	push cx
  1856 000006A6 9C                      	pushf
  1857 000006A7 E329                    	jcxz .done		; nothing to do -->
  1858                                  .loop:
  1859 000006A9 E8E400                  	call gg_writepoints_restore	; Restore breakpoint bytes.
  1860 000006AC 7324                    	jnc .done		; successful -->
  1861 000006AE 5A                      	pop dx			; discard flags
  1862 000006AF 5B                      	pop bx
  1863 000006B0 53                      	push bx
  1864 000006B1 9C                      	pushf			; store (CY) flags
  1865                                  
  1866 000006B2 50                      	push ax
  1867 000006B3 89F7                    	mov di, si
  1868 000006B5 81EF[0900]              	sub di, BPSIZE+g_bplist.bp
  1869                                  %if BPSIZE == 5 || BPSIZE == 6 || BPSIZE == 9
  1870 000006B9 89F8                    	mov ax, di
  1871 000006BB 31D2                    	xor dx, dx
  1872 000006BD BF0900                  	mov di, BPSIZE
  1873 000006C0 F7F7                    	div di
  1874 000006C2 89C7                    	mov di, ax		; di = 0-based point index
  1875 000006C4 D1E7                    	shl di, 1		; di = 0-based error info offset
  1876                                  %elif BPSIZE == 4
  1877                                  	shr di, 1		; di = 0-based error info offset
  1878                                  %else
  1879                                   %error "Unexpected BPSIZE"
  1880                                  %endif
  1881 000006C6 29DF                    	sub di, bx
  1882 000006C8 29DF                    	sub di, bx
  1883 000006CA 8F03                    	pop word [bp+di]	; store error info
  1884 000006CC 49                      	dec cx			; exclude the failed point
  1885 000006CD 83EE12                  	sub si, 2*BPSIZE	; -> the point _before_ failed one
  1886 000006D0 EBD7                    	jmp short .loop
  1887                                  .done:
  1888 000006D2 9D                      	popf			; get flags. CY if any couldn't be restored
  1889 000006D3 59                      	pop cx			; restore cx
  1890 000006D4 C3                      	retn
  1891                                  %endif
  1892                                  
  1893                                  
  1894                                  %if _BREAKPOINTS
  1895                                  		; INP:	ss:bp -> error info space (one word per bb breakpoint)
  1896                                  		; OUT:	error info space initialised to all zeros
  1897                                  		; CHG:	ax, di, es
  1898                                  		; STT:	sets es to ss
  1899                                  		;
  1900                                  		; Note:	This initialises words for all bb points.
  1901                                  		;	 While the value in cx is preserved, it is
  1902                                  		;	 assumed that space for all points is allocated.
  1903                                  bb_restorepoints_init_error_info:
  1904 000006D5 16                      	push ss
  1905 000006D6 07                      	pop es
  1906 000006D7 89EF                    	mov di, bp
  1907 000006D9 31C0                    	xor ax, ax
  1908 000006DB 51                      	push cx
  1909 000006DC B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  1910 000006DF F3AB                    	rep stosw
  1911 000006E1 59                      	pop cx
  1912 000006E2 C3                      	retn
  1913                                  
  1914                                  
  1915                                  bb_restorepoints_and_init_error_info:
  1916 000006E3 E8EFFF                  	call bb_restorepoints_init_error_info
  1917                                  
  1918                                  		; Restore bb breakpoints.
  1919                                  		; On errors remember failures but restore all remaining anyway.
  1920                                  		;
  1921                                  		; INP:	cx = index above last one to restore
  1922                                  		;	ss:bp -> error info space (one word per bb breakpoint)
  1923                                  		; OUT:	NC if all points restored successfully
  1924                                  		;	CY if at least one point couldn't be restored,
  1925                                  		;	 error info filled, high byte:
  1926                                  		;	  reason =	0 = no error (this point didn't fail),
  1927                                  		;			1 = couldn't write,
  1928                                  		;			2 = unreachable,
  1929                                  		;			3 = overwritten),
  1930                                  		;	  low byte: new byte value (if reason 3)
  1931                                  		; CHG:	ax, bx, cx, (e)dx, si, di, es
  1932                                  		; STT:	sets es to ss
  1933                                  		;	might return modeswitched
  1934                                  		;
  1935                                  		; Note:	The points are restored in reverse, from the list back
  1936                                  		;	 to the front. The first point is handled last.
  1937                                  bb_restorepoints:
  1938                                  
  1939 000006E6 F8                      	clc			; assume success
  1940 000006E7 9C                      	pushf
  1941 000006E8 E30F                    	jcxz .done
  1942                                  .loop:
  1943 000006EA E81400                  	call bb_writepoints_restore
  1944 000006ED 730A                    	jnc .done
  1945 000006EF 5A                      	pop dx			; (discard flags)
  1946 000006F0 9C                      	pushf			; store (CY) flags
  1947                                  				; cx = index of point that failed to write
  1948                                  				; ah = reason, al = new byte value (reason 3)
  1949 000006F1 89CF                    	mov di, cx
  1950 000006F3 01FF                    	add di, di
  1951 000006F5 8903                    	mov word [bp + di], ax	; store error info
  1952 000006F7 EBF1                    	jmp .loop
  1953                                  
  1954                                  .done:
  1955 000006F9 9D                      	popf			; CF
  1956 000006FA C3                      	retn
  1957                                  
  1958                                  
  1959                                  		; Loop through bb breakpoints and exchange the saved
  1960                                  		; byte with that one at the actual address. Used to write
  1961                                  		; the breakpoints.
  1962                                  		;
  1963                                  		; INP:	-
  1964                                  		; OUT:	NC if successful
  1965                                  		;	CY if error writing a point,
  1966                                  		;	 cx = index of point that failed to write
  1967                                  		;	 (all PRIOR points were processed successfully,
  1968                                  		;	  either written successfully or skipped)
  1969                                  		; CHG:	ax, bx, (e)dx, si, cx, di
  1970                                  		; STT:	might return modeswitched
  1971                                  bb_writepoints:
  1972 000006FB 31C9                    	xor cx, cx
  1973 000006FD BF0100                  	mov di, 1
  1974 00000700 A9                      	db __TEST_IMM16		; (skip xor, NC)
  1975                                  
  1976                                  		; Same, but go through the breakpoints in reverse order
  1977                                  		; and check that what we overwrite is a 0CCh byte. If so,
  1978                                  		; restore the original value. (The 0CCh is discarded.)
  1979                                  		;
  1980                                  		; INP:	cx = index *above* last to write
  1981                                  		;	 (_NUM_B_BP + _NUM_SYM_BP for all)
  1982                                  		; OUT:	NC if successful
  1983                                  		;	CY if error writing a point,
  1984                                  		;	 cx = index of point that failed to write
  1985                                  		;	 ah = 1 if error because point could not be written
  1986                                  		;	 ah = 2 if error because address is unreachable
  1987                                  		;	 ah = 3 if error because point contained non-0CCh value,
  1988                                  		;	  al = new byte
  1989                                  		; CHG:	ax, bx, (e)dx, si, cx, di
  1990                                  		; STT:	might return modeswitched
  1991                                  bb_writepoints_restore:
  1992 00000701 31FF                    	xor di, di		; (NC)
  1993                                  bb_wp:
  1994                                  	lframe near
  1995 00000703 5589E5                  	lenter
  1996                                  	lvar	word, is_write
  1997 00000706 57                      	 push di
  1998                                  
  1999 00000707 F646FE01                	test byte [bp + ?is_write], 1
  2000                                  				; (NC) is it writing ?
  2001 0000070B 7459                    	jz .next		; no, is restoring, first decrement cx -->
  2002                                  
  2003                                  .loop:
  2004 0000070D 89C8                    	mov ax, cx
  2005 0000070F E8(0000)                	call calcpointbit	; bx = index, ah = value
  2006 00000712 84A7[0000]              	test byte [b_bplist.used_mask+bx], ah
  2007                                  				; (NC)
  2008 00000716 744E                    	jz .next
  2009 00000718 84A7[0000]              	test byte [b_bplist.disabled_mask+bx], ah
  2010                                  				; (NC)
  2011 0000071C 7548                    	jnz .next
  2012                                  
  2013 0000071E 89CE                    	mov si, cx
  2014 00000720 01F6                    	add si, si
  2015 00000722 01F6                    	add si, si		; * 4
  2016                                  %if BPSIZE == 4
  2017                                  %elif BPSIZE == 5
  2018                                  	add si, cx		; * 5
  2019                                  %elif BPSIZE == 6
  2020                                  	add si, cx		; * 5
  2021                                  	add si, cx		; * 6
  2022                                  %elif BPSIZE == 9
  2023 00000724 01F6                    	add si, si		; * 8
  2024 00000726 01CE                    	add si, cx		; * 9
  2025                                  %else
  2026                                   %error Unexpected breakpoint size
  2027                                  %endif
  2028 00000728 81C6[0000]              	add si, b_bplist.bp	; -> point
  2029                                  
  2030 0000072C E866FE                  	call gg_bb_lods_bp_linear
  2031                                  				; dx:ax = linear address
  2032                                  
  2033 0000072F E8B700                  	call gg_bb_check_is_first
  2034 00000732 7332                    	jnc .next		; (NC)
  2035                                  
  2036 00000734 E80203                  	call getsegmented	; bx:(e)dx = segmented address
  2037                                  %if BPSIZE == 6
  2038                                  	lodsw			; skip word offset
  2039                                  %elif BPSIZE == 9
  2040 00000737 AD                      	lodsw
  2041 00000738 AD                      	lodsw			; skip dword offset
  2042                                  %endif
  2043 00000739 AC                      	lodsb			; get byte to write
  2044 0000073A B402                    	mov ah, 2
  2045 0000073C 723E                    	jc .return		; not in PM anymore/address not available --> (CY)
  2046 0000073E F646FE01                	test byte [bp + ?is_write], 1
  2047                                  				; writing?
  2048 00000742 7517                    	jnz .forward_nocheck	; yes -->
  2049                                  
  2050                                  .backward_check:
  2051 00000744 50                      	push ax
  2052 00000745 E8(0000)                	call readmem		; read current byte
  2053 00000748 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  2054 0000074A B483                    	mov ah, 83h		; (80h = error occurred while restoring)
  2055 0000074C F9                      	stc
  2056 0000074D 752D                    	jne .return_discard	; nope --> (CY)
  2057 0000074F 58                      	pop ax
  2058 00000750 E8(0000)                	call writemem		; return the byte to its original value
  2059 00000753 7211                    	jc .next		; failed --> (CY, handled there)
  2060 00000755 C644FFCC                	mov byte [si-1], 0CCh	; reset stored point
  2061 00000759 EB0B                    	jmp short .next
  2062                                  
  2063                                  .forward_nocheck:
  2064                                  %if _DELAY_BEFORE_BP
  2065 0000075B E887FE                  	call delay_before_bp
  2066                                  %endif
  2067 0000075E E8(0000)                	call writemem
  2068 00000761 7203                    	jc .next
  2069 00000763 8844FF                  	mov byte [si-1], al	; save the previous byte there
  2070                                  .next:
  2071 00000766 B401                    	mov ah, 1		; (in case of error)
  2072 00000768 7212                    	jc .return		; failed to write --> (CY)
  2073                                  
  2074 0000076A F646FE01                	test byte [bp + ?is_write], 1
  2075 0000076E 7505                    	jnz .is_write_next
  2076 00000770 49                      	dec cx			; restore: decrement index
  2077 00000771 799A                    	jns .loop		; decremented to 0FFFFh ?  no, loop -->
  2078 00000773 EB06                    	jmp .return_NC
  2079                                  
  2080                                  .is_write_next:
  2081 00000775 41                      	inc cx			; write: increment index
  2082 00000776 83F910                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  2083                                  				; above last ?
  2084 00000779 7292                    	jb .loop		; no, loop -->
  2085                                  .return_NC:
  2086 0000077B F8                      	clc
  2087                                  .return:
  2088                                  .return_discard:
  2089 0000077C 730A                    	jnc .ret
  2090                                  
  2091 0000077E F646FE01                	test byte [bp + ?is_write], 1
  2092                                  				; restoring ?
  2093 00000782 7503                    	jnz .ret_CY		; no -->
  2094 00000784 80CC80                  	or ah, 80h		; error occurred while restoring
  2095                                  .ret_CY:
  2096 00000787 F9                      	stc
  2097                                  .ret:
  2098 00000788 89EC5D                  	lleave
  2099 0000078B C3                      	lret
  2100                                  %endif
  2101                                  
  2102                                  
  2103                                  %if _NUM_G_BP
  2104                                  		; Loop through saved breakpoints and exchange the saved
  2105                                  		; byte with that one at the actual address. Used to write
  2106                                  		; the breakpoints.
  2107                                  		;
  2108                                  		; INP:	si-> current point
  2109                                  		;	cx = number of points to write (might be zero)
  2110                                  		; OUT:	NC if successful
  2111                                  		;	CY if error writing a point,
  2112                                  		;	 cx = number of points still to write (including failed one)
  2113                                  		;	 (si-BPSIZE)-> point that failed
  2114                                  		; CHG:	ax, bx, (e)dx, si, cx, di
  2115                                  gg_writepoints:
  2116 0000078C BF0100                  	mov di, 1
  2117 0000078F A9                      	db __TEST_IMM16		; (skip xor, NC)
  2118                                  
  2119                                  		; Same, but go through the breakpoints in reverse order
  2120                                  		; and check that what we overwrite is a 0CCh byte. If so,
  2121                                  		; restore the original value. (The 0CCh is discarded.)
  2122                                  		;
  2123                                  		; Additionally:
  2124                                  		; OUT:	CY if error writing a point,
  2125                                  		;	 ah = 1 if error because point could not be written
  2126                                  		;	 ah = 2 if error because address is unreachable
  2127                                  		;	 ah = 3 if error because point contained non-0CCh value,
  2128                                  		;	  al = new byte
  2129                                  gg_writepoints_restore:
  2130 00000790 31FF                    	xor di, di		; (NC)
  2131                                  gg_wp:
  2132 00000792 E348                    	jcxz .return		;if nothing to do --> (still NC from xor/test)
  2133                                  .loop:
  2134 00000794 E8FEFD                  	call gg_bb_lods_bp_linear
  2135                                  				; dx:ax = linear address
  2136                                  
  2137 00000797 E84F00                  	call gg_bb_check_is_first
  2138 0000079A 7209                    	jc @F			; if to handle this breakpoint -->
  2139                                  
  2140                                  		; Skip to next breakpoint.
  2141                                  %if BPSIZE == 4 || BPSIZE == 5
  2142                                  	inc si			; -> after point
  2143                                  %elif BPSIZE == 6
  2144                                  	add si, 3		; skip word offset and byte content
  2145                                  %elif BPSIZE == 9
  2146 0000079C 83C605                  	add si, 5		; skip dword offset and byte content
  2147                                  %endif
  2148                                  				; BPSIZE implied
  2149                                  
  2150 0000079F 85FF                    	test di, di		; (NC)
  2151 000007A1 7533                    	jnz .next		; going forward -->
  2152 000007A3 EB23                    	jmp .next_lea_si	; (NC)
  2153                                  
  2154                                  		; Handle this breakpoint.
  2155                                  @@:
  2156 000007A5 E89102                  	call getsegmented	; bx:(e)dx = segmented address
  2157                                  %if BPSIZE == 6
  2158                                  	lodsw			; skip word offset
  2159                                  %elif BPSIZE == 9
  2160 000007A8 AD                      	lodsw
  2161 000007A9 AD                      	lodsw			; skip dword offset
  2162                                  %endif
  2163 000007AA AC                      	lodsb			; get byte to write
  2164 000007AB B402                    	mov ah, 2
  2165 000007AD 722D                    	jc .return		; not in PM anymore/address not available --> (CY)
  2166 000007AF 85FF                    	test di, di		; writing?
  2167 000007B1 751A                    	jnz .forward_nocheck	; yes -->
  2168                                  
  2169                                  .backward_check:
  2170 000007B3 50                      	push ax
  2171 000007B4 E8(0000)                	call readmem		; read current byte
  2172 000007B7 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  2173 000007B9 B483                    	mov ah, 83h		; (80h = error occurred while restoring)
  2174 000007BB F9                      	stc
  2175 000007BC 7529                    	jne .return_discard	; nope --> (CY)
  2176 000007BE 58                      	pop ax
  2177 000007BF E8(0000)                	call writemem		; return the byte to its original value
  2178 000007C2 7212                    	jc .next		; failed --> (CY, handled there)
  2179 000007C4 C644FFCC                	mov byte [si-1], 0CCh	; reset stored point
  2180                                  .next_lea_si:
  2181 000007C8 8D74EE                  	lea si, [si-2*BPSIZE]	; adjust (for reverse writing)
  2182 000007CB EB09                    	jmp short .next
  2183                                  
  2184                                  .forward_nocheck:
  2185                                  %if _DELAY_BEFORE_BP
  2186 000007CD E815FE                  	call delay_before_bp
  2187                                  %endif
  2188 000007D0 E8(0000)                	call writemem
  2189 000007D3 8844FF                  	mov byte [si-1], al	; save the previous byte there
  2190                                  .next:
  2191 000007D6 B401                    	mov ah, 1		; (in case of error)
  2192 000007D8 7202                    	jc .return		; failed to write --> (CY)
  2193 000007DA E2B8                    	loop .loop
  2194                                  .return:			; (NC)
  2195 000007DC 730A                    	jnc .ret
  2196                                  
  2197 000007DE 85FF                    	test di, di		; restoring ?
  2198 000007E0 7503                    	jnz .ret_CY		; no -->
  2199 000007E2 80CC80                  	or ah, 80h		; error occurred while restoring
  2200                                  .ret_CY:
  2201 000007E5 F9                      	stc
  2202 000007E6 52                      	push dx			; (counteract effect of pop)
  2203                                  .return_discard:
  2204 000007E7 5A                      	pop dx
  2205                                  .ret:
  2206 000007E8 C3                      	retn
  2207                                  %endif
  2208                                  
  2209                                  
  2210                                  		; INP:	dx:ax = linear address of point to be (re)set
  2211                                  		;	dword [internalflags2]
  2212                                  		;	dword [gg_first_cseip_linear]
  2213                                  		; OUT:	CY if to (re)set breakpoint
  2214                                  		;	 if: no flag set
  2215                                  		;	 or: dx:ax doesn't match, dif2_gg_skip_non_cseip clear
  2216                                  		;		(setting non-cseip point)
  2217                                  		;	 or: dx:ax matches, dif2_gg_skip_cseip clear
  2218                                  		;		(setting cseip point afterwards)
  2219                                  		;	NC if to not (re)set breakpoint
  2220                                  		;	 if: dx:ax doesn't match, dif2_gg_skip_non_cseip set
  2221                                  		;		(not setting non-cseip point afterwards)
  2222                                  		;	 or: dx:ax matches, dif2_gg_skip_cseip set
  2223                                  		;		(not setting cseip point)
  2224                                  gg_bb_check_is_first:
  2225 000007E9 F606[0000]07            	testopt [internalflags2], 		dif2_gg_is_first | dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  2227 000007EE 7418                    	jz .continue
  2228                                  
  2229 000007F0 3906[0000]              	cmp [gg_first_cseip_linear], ax
  2230 000007F4 7514                    	jne .is_not_first
  2231 000007F6 3916[0200]              	cmp [gg_first_cseip_linear + 2], dx
  2232 000007FA 750E                    	jne .is_not_first
  2233                                  
  2234                                  .is_first:
  2235 000007FC 800E[0000]10            	setopt [internalflags2], dif2_gg_first_detected
  2236 00000801 F606[0000]04            	testopt [internalflags2], dif2_gg_skip_cseip
  2237 00000806 7509                    	jnz .skip
  2238                                  .continue:
  2239 00000808 F9                      	stc
  2240 00000809 C3                      	retn
  2241                                  
  2242                                  .is_not_first:
  2243 0000080A F606[0000]02            	testopt [internalflags2], dif2_gg_skip_non_cseip
  2244 0000080F 74F7                    	jz .continue
  2245                                  .skip:
  2246 00000811 F8                      	clc
  2247 00000812 C3                      	retn
  2248                                  
  2249                                  
  2250                                  		; INP:	al = number to put
  2251                                  		; OUT:	putsline called with ordinal string
  2252                                  		; CHG:	di, [line_out], ax
  2253                                  putordinalbyte:
  2254 00000813 53                      	push bx
  2255 00000814 51                      	push cx
  2256 00000815 52                      	push dx
  2257                                  
  2258                                  		; Note that trim_overflow in front of line_out is
  2259                                  		;  initialised to '0', which we depend on here.
  2260                                  		;  With the output from decbyte, at least two decimal
  2261                                  		;  digits are always valid in the buffer.
  2262 00000816 BF[0000]                	mov di, line_out
  2263 00000819 E80700                  	call ordinalbyte
  2264 0000081C E8(0000)                	call putsline
  2265 0000081F 5A                      	pop dx
  2266 00000820 59                      	pop cx
  2267 00000821 5B                      	pop bx
  2268 00000822 C3                      	retn
  2269                                  
  2270                                  
  2271                                  ordinalbyte:
  2272 00000823 E8(0000)                	call decbyte
  2273 00000826 8B45FE                  	mov ax, [di - 2]	; al = lower address, higher decimal digit
  2274                                  				; ah = higher address, lower decimal digit
  2275 00000829 3C31                    	cmp al, '1'
  2276 0000082B 7417                    	je .gotsuf_th		; 11th, 12th, 13th or other teen -->
  2277 0000082D BA7374                  	mov dx, "st"
  2278 00000830 80FC31                  	cmp ah, '1'
  2279 00000833 7412                    	je .gotsuf		; if low digit was one -->
  2280 00000835 BA6E64                  	mov dx, "nd"
  2281 00000838 80FC32                  	cmp ah, '2'
  2282 0000083B 740A                    	je .gotsuf		; if low digit was two -->
  2283 0000083D B272                    	mov dl, 'r'
  2284 0000083F 80FC33                  	cmp ah, '3'
  2285 00000842 7403                    	je .gotsuf		; if low digit was three -->
  2286                                  .gotsuf_th:
  2287 00000844 BA7468                  	mov dx, "th"
  2288                                  .gotsuf:
  2289 00000847 89D0                    	mov ax, dx
  2290 00000849 AB                      	stosw
  2291 0000084A C3                      	retn
  2292                                  
  2293                                  
  2294                                  %if _BREAKPOINTS
  2295                                  		; INP:	ss:bp -> error info (points at first info word)
  2296                                  		;	 Each word provides information for one point we tried
  2297                                  		;	 to restore. The lowest info word corresponds to the
  2298                                  		;	 first bb breakpoint (bb 00), followed by the info word
  2299                                  		;	 for the second bb breakpoint (bb 01), and so on.
  2300                                  		;	 There are always as many info words as there are
  2301                                  		;	 bb breakpoints.
  2302                                  		; CHG:	ax, bx, cx, dx, di, si
  2303                                  		; STT:	sets es to ss
  2304                                  bb_handlefailedrestore:
  2305                                  %if _PM
  2306 0000084B E8C601                  	call resetmode
  2307                                  %endif
  2308 0000084E 31FF                    	xor di, di
  2309 00000850 31C9                    	xor cx, cx
  2310 00000852 16                      	push ss
  2311 00000853 07                      	pop es
  2312 00000854 BE[0000]                	mov si, b_bplist.bp
  2313                                  .loop:
  2314 00000857 8B03                    	mov ax, word [bp + di]
  2315 00000859 F6C47F                  	test ah, 7Fh		; failed ?
  2316 0000085C 7414                    	jz .next
  2317 0000085E 51                      	push cx
  2318 0000085F 57                      	push di
  2319                                  				; cx = 0-based index
  2320 00000860 FF7402                  	 push word [si + 2]
  2321 00000863 FF34                    	 push word [si]		; stack: linear address
  2322 00000865 8A5C08                  	mov bl, byte [si + BPSIZE - 1]
  2323                                  				; bl = what we tried to restore
  2324 00000868 B740                    	mov bh, 40h		; bh = 40h (bb)
  2325 0000086A 80CC80                  	or ah, 80h		; ah & 80h = set (is restore)
  2326 0000086D E8850C                  	call display_breakpoint_failure
  2327 00000870 5F                      	pop di
  2328 00000871 59                      	pop cx
  2329                                  .next:
  2330 00000872 83C609                  	add si, BPSIZE
  2331 00000875 AF                      	scasw			; di += 2
  2332 00000876 41                      	inc cx
  2333 00000877 83F910                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  2334 0000087A 72DB                    	jb .loop
  2335                                  .end:
  2336 0000087C C3                      	retn
  2337                                  %endif
  2338                                  
  2339                                  
  2340                                  %if _NUM_G_BP
  2341                                  		; INP:	cx = number of restored points (number of info words)
  2342                                  		;	ss:bp-> error info (points *behind* last info word)
  2343                                  		;	 Each word provides information for one point we tried
  2344                                  		;	 to restore. The lowest info word corresponds to the
  2345                                  		;	 first gg breakpoint, followed by the info word for
  2346                                  		;	 the second gg breakpoint (if any), and so on.
  2347                                  		; CHG:	ax, bx, cx, dx, di, si
  2348                                  		; STT:	sets es to ss
  2349                                  gg_handlefailedrestore:
  2350                                  %if _PM
  2351 0000087D E89401                  	call resetmode
  2352                                  %endif
  2353 00000880 89CF                    	mov di, cx
  2354 00000882 01FF                    	add di, di
  2355 00000884 F7DF                    	neg di
  2356 00000886 16                      	push ss
  2357 00000887 07                      	pop es
  2358 00000888 BB0000                  	mov bx, 0
  2359 0000088B BE[0000]                	mov si, g_bplist.bp
  2360 0000088E E325                    	jcxz .end
  2361                                  .loop:
  2362 00000890 8B03                    	mov ax, word [bp+di]
  2363 00000892 F6C47F                  	test ah, 7Fh		; failed?
  2364 00000895 7416                    	jz .next		; no -->
  2365                                  
  2366                                  		; si-> point
  2367                                  		; ax = info (ah = reason, al = new value if reason 3)
  2368                                  		; bx = point's 0-based index
  2369                                  .display:
  2370 00000897 53                      	push bx
  2371 00000898 57                      	push di
  2372 00000899 89D9                    	mov cx, bx		; cx = 0-based index
  2373 0000089B FF7402                  	 push word [si + 2]
  2374 0000089E FF34                    	 push word [si]		; stack: linear address
  2375 000008A0 8A5C08                  	mov bl, byte [si + BPSIZE - 1]
  2376                                  				; bl = what we tried to restore
  2377 000008A3 B780                    	mov bh, 80h		; bh = 80h (gg)
  2378 000008A5 80CC80                  	or ah, 80h		; ah & 80h = set (is restore)
  2379 000008A8 E84A0C                  	call display_breakpoint_failure
  2380 000008AB 5F                      	pop di
  2381 000008AC 5B                      	pop bx
  2382                                  .next:
  2383 000008AD 43                      	inc bx			; increment counter
  2384 000008AE 83C609                  	add si, BPSIZE		; -> next point
  2385 000008B1 47                      	inc di
  2386 000008B2 47                      	inc di			; di+bp-> next error info
  2387 000008B3 75DB                    	jnz .loop		; not yet at end -->
  2388                                  .end:
  2389 000008B5 C3                      	retn
  2390                                  %endif	; _NUM_G_BP
  2391                                  
  2392                                  
  2393                                  		; INP:	word [reg_cs]
  2394                                  		;	(d)word [reg_eip]
  2395                                  		; OUT:	bx = word [reg_cs]
  2396                                  		;	CY if invalid address
  2397                                  		;	NC if address is valid,
  2398                                  		;	 dx:ax = linear address
  2399                                  		; CHG:	edx, ax, ecx
  2400                                  get_cseip_minus_1_linear:
  2401 000008B6 66                      	_386_PM_o32		; or ecx, byte -1
  2402 000008B7 83C9FF                  	or cx, byte -1
  2403                                  
  2404                                  		; INP:	word [reg_cs]
  2405                                  		;	(d)word [reg_eip]
  2406                                  		;	(e)cx = adjustment to (e)ip
  2407                                  		; OUT:	bx = word [reg_cs]
  2408                                  		;	CY if invalid address
  2409                                  		;	NC if address is valid,
  2410                                  		;	 dx:ax = linear address
  2411                                  		; CHG:	edx, ax
  2412                                  get_cseip_ecx_linear:
  2413 000008BA 8B1E[0000]              	mov bx, [reg_cs]	; bx = cs
  2414 000008BE 66                      	_386_PM_o32
  2415 000008BF 8B16[0000]              	mov dx, [reg_eip]	; (e)dx = (e)ip
  2416 000008C3 66                      	_386_PM_o32
  2417 000008C4 01CA                    	add dx, cx		; bx:(e)dx = adjusted cs:(e)ip
  2418                                  			; (getlinear doesn't use the high word of edx if it's a 16-bit cs)
  2419                                  	; call getlinear	; dx:ax = linear address of this cs:eip
  2420                                  	; (fall through to getlinear_d_b)
  2421                                  %endif	; !_LOADER
  2422                                  
  2423                                  
  2424                                  		; INP:	If currently in RM,
  2425                                  		;	 bx:dx = segment:offset of address
  2426                                  		;	If currently in PM,
  2427                                  		;	 bx:(e)dx = selector:offset of address
  2428                                  		; OUT:	bx = unchanged (selector/segment)
  2429                                  		;	CY if address is invalid,
  2430                                  		;	 because Int31.0006 failed for bx or
  2431                                  		;	 because 32-bit address overflowed or
  2432                                  		;	 because A20 could not be switched on
  2433                                  		;	NC if address is valid,
  2434                                  		;	 dx:ax = linear address
  2435                                  		;	 dh is always zero if the address is in RM address space
  2436                                  		; CHG:	dx, ax
  2437                                  %if _PM
  2438                                  getlinear_d_b: section_of_function
  2439 000008C6 57                      	push di
  2440 000008C7 BF[0000]                	mov di, test_d_b_bit
  2441 000008CA E82300                  	call getlinear_common
  2442 000008CD 5F                      	pop di
  2443 000008CE C3                      	retn
  2444                                  
  2445                                  getlinear_high_limit: section_of_function
  2446 000008CF 57                      	push di
  2447 000008D0 BF[0000]                	mov di, test_high_limit
  2448 000008D3 E81A00                  	call getlinear_common
  2449 000008D6 5F                      	pop di
  2450 000008D7 C3                      	retn
  2451                                  
  2452                                  getlinear_32bit: section_of_function
  2453 000008D8 57                      	push di
  2454 000008D9 BF[E108]                	mov di, .always_NZ
  2455 000008DC E81100                  	call getlinear_common
  2456 000008DF 5F                      	pop di
  2457 000008E0 C3                      	retn
  2458                                  
  2459                                  .always_NZ:
  2460 000008E1 85FF                    	test di, di
  2461 000008E3 C3                      	retn
  2462                                  
  2463                                  section_of getlinear_16bit
  2464                                  getlinear_16bit: section_of_function
  2465 000008E4 57                      	push di
  2466 000008E5 BF[ED08]                	mov di, .always_ZR
  2467 000008E8 E80500                  	call getlinear_common
  2468 000008EB 5F                      	pop di
  2469 000008EC C3                      	retn
  2470                                  
  2471                                  .always_ZR:
  2472 000008ED 39FF                    	cmp di, di
  2473 000008EF C3                      	retn
  2474                                  
  2475                                   %if _DEBUG1
  2476                                  getlinear_high_limit.do_not_use_test: section_of_function
  2477                                  		; DO NOT use resetmode, called by readmem/writemem
  2478                                  	push di
  2479                                  	mov di, test_d_b_bit
  2480                                  	call getlinear_common.do_not_use_test
  2481                                  	pop di
  2482                                  	retn
  2483                                   %endif
  2484                                  %else
  2485                                  check_section_of getlinear_d_b
  2486                                  check_section_of getlinear_high_limit
  2487                                  check_section_of getlinear_32bit
  2488                                  getlinear_d_b: equ getlinear_common
  2489                                  getlinear_high_limit: equ getlinear_common
  2490                                  getlinear_32bit: equ getlinear_common
  2491                                  getlinear_16bit: equ getlinear_common
  2492                                   %if _DEBUG1
  2493                                  check_section_of getlinear_high_limit.do_not_use_test
  2494                                  getlinear_high_limit.do_not_use_test: equ getlinear_common.do_not_use_test
  2495                                   %endif
  2496                                  %endif
  2497                                  
  2498                                  
  2499                                  		; Internal entry: Call function di to determine use
  2500                                  		;  of a 32-bit offset, INP: bx = seg/sel, OUT: NZ iff 32-bit
  2501                                  getlinear_common: section_of_function
  2502                                  %if _PM
  2503 000008F0 E82101                  	call resetmode
  2504                                  				; This must execute in the correct mode,
  2505                                  				;  because we get the input from whatever
  2506                                  				;  mode we were originally entered in.
  2507                                  %endif
  2508                                  %if _DEBUG1
  2509                                  	call .do_not_use_test	; get linear address
  2510                                  	jc @F			; already an error ?  then return -->
  2511                                  	push bx
  2512                                  	push cx
  2513                                  	mov bx, test_records_getLinear
  2514                                  	call handle_test_case_multiple_16
  2515                                  				; check whether this should testcase the error
  2516                                  				; CY to indicate error from this call
  2517                                  	pop cx
  2518                                  	pop bx
  2519                                  @@:
  2520                                  	retn
  2521                                  
  2522                                  %endif
  2523                                  		; DOES NOT use resetmode
  2524                                  .do_not_use_test:
  2525 000008F3 53                      	 push bx
  2526                                  %if _PM
  2527 000008F4 E8(0000)                	call ispm
  2528 000008F7 7520                    	jnz .rm
  2529 000008F9 B80600                  	mov ax, 0006h
  2530 000008FC 51                      	 push cx
  2531 000008FD 52                      	push dx
  2532 000008FE CD31                    	int 31h			; get selector base address into cx:dx
  2533 00000900 58                      	pop ax			; (edxh:)ax = offset, cx:dx = base
  2534 00000901 7213                    	jc .return_cx_bx
  2535                                  
  2536 00000903 FFD7                    _386	call di
  2537 00000905 7406                    _386	jz .16
  2538 00000907 6652                    _386	push edx
  2539 00000909 5B                      _386	pop bx
  2540 0000090A 5B                      _386	pop bx			; bx = high word edx (in 32-bit PM segment)
  2541 0000090B EB02                    _386	jmp .32
  2542                                  .16:				; bx:ax = offset
  2543 0000090D 31DB                    	xor bx, bx		; 16-bit PM segment, clear offset high word
  2544                                  .32:
  2545 0000090F 01D0                    	add ax, dx
  2546 00000911 11CB                    	adc bx, cx		; add the base
  2547 00000913 87DA                    	xchg bx, dx		; dx:ax = 32-bit linear address
  2548 00000915 F8                      	clc
  2549                                  
  2550                                  .return_cx_bx:
  2551 00000916 59                      	 pop cx
  2552 00000917 5B                      	 pop bx
  2553 00000918 C3                      	retn
  2554                                  .rm:
  2555                                  %endif
  2556 00000919 89D8                    	mov ax, bx
  2557 0000091B 51                      	push cx
  2558 0000091C B104                    	mov cl, 4
  2559 0000091E D3C0                    	rol ax, cl
  2560 00000920 59                      	pop cx
  2561 00000921 BBF0FF                  	mov bx, 0FFF0h
  2562 00000924 21C3                    	and bx, ax		; bx = low word adjustment
  2563 00000926 83E00F                  	and ax, byte 0Fh	; ax = higher bits which don't fit in the low word
  2564 00000929 01DA                    	add dx, bx
  2565 0000092B 83D000                  	adc ax, byte 0
  2566 0000092E 92                      	xchg ax, dx		; dx:ax = 21-bit linear address
  2567 0000092F F606[0100]10            	testopt [internalflags], debuggeeA20
  2568 00000934 7503                    	jnz .return_bx		; A20 line enabled, no need to adjust (NC)
  2569 00000936 80E2EF                  	and dl, ~10h		; clear corresponding bit of the address if it was set (NC)
  2570                                  .return_bx:
  2571 00000939 5B                      	 pop bx
  2572 0000093A C3                      	retn
  2573                                  
  2574                                  
  2575                                  		; INP:	bx = segment/selector to use by default
  2576                                  		;	al = next character in input
  2577                                  		;	si -> following character in input
  2578                                  		; OUT:	NC if successful,
  2579                                  		;	 bx:dx = linear address
  2580                                  		;		(if not _PM, this always fits in 24 bits)
  2581                                  		;	 al = next character
  2582                                  		;	 si -> following character
  2583                                  		;	 (d)word [bp_offset] = preferred offset, -1 if none
  2584                                  		;	CY if error
  2585                                  		; CHG:	edx, bx, ax, si, (d)word [bp_offset]
  2586                                  getlinearaddr: section_of_function
  2587                                  %if _PM
  2588 0000093B E8D600                  	call resetmode
  2589                                  %endif
  2590                                  %if !_LOADER
  2591 0000093E 66                      	_386_PM_o32	; or dword
  2592 0000093F 830E[0000]FF            	or word [bp_offset], strict byte -1
  2593                                  %endif
  2594 00000944 E8(0000)                	call skipcomm0
  2595 00000947 3C40                    	cmp al, '@'
  2596 00000949 7530                    	jne .at_not
  2597 0000094B AC                      	lodsb			; insure we have a blank or opening parens
  2598 0000094C 3C28                    	cmp al, '('
  2599 0000094E 740A                    	je .at
  2600 00000950 3C09                    	cmp al, 9
  2601 00000952 7406                    	je .at
  2602 00000954 3C20                    	cmp al, 32
  2603 00000956 7402                    	je .at
  2604 00000958 EB1E                    	jmp .at_not_reload	; assume the @ is part of a symbol
  2605                                  
  2606                                  .at:
  2607 0000095A E8(0000)                	call skipwh0
  2608 0000095D 3C28                    	cmp al, '('
  2609 0000095F 7510                    	jne .at_not_paren
  2610                                  
  2611 00000961 AC                      	lodsb
  2612 00000962 E8(0000)[0000]          	nearcall getdword
  2613 00000967 E8(0000)                	call skipwh0
  2614 0000096A 3C29                    	cmp al, ')'
  2615 0000096C 7525                    	jne .error
  2616 0000096E AC                      	lodsb
  2617                                  
  2618 0000096F EB05                    	jmp .at_got
  2619                                  
  2620                                  .at_not_paren:
  2621 00000971 E8(0000)[0000]          	nearcall getdword
  2622                                  .at_got:
  2623                                  %ifn _PM
  2624                                  	; test bh, bh
  2625                                  	; jnz .error
  2626                                  	cmp bx, 11h
  2627                                  	jae .error
  2628                                  %endif
  2629 00000976 F8                      	clc
  2630 00000977 C3                      	retn
  2631                                  
  2632                                  .at_not_reload:
  2633 00000978 4E                      	dec si
  2634 00000979 4E                      	dec si
  2635 0000097A AC                      	lodsb
  2636                                  .at_not:
  2637 0000097B E8(0000)[0000]          	nearcall getaddrX
  2638                                  %if _PM
  2639 00000980 8326[0200]00            _no386	and word [bp_offset + 2], 0
  2640                                  %endif
  2641                                  %if !_LOADER
  2642 00000985 66                      	_386_PM_o32		; mov dword [bp_offset], edx
  2643 00000986 8916[0000]              	mov word [bp_offset], dx
  2644                                  %endif
  2645 0000098A 50                      	push ax
  2646 0000098B E841FF                  	call getlinear_high_limit
  2647 0000098E 93                      	xchg bx, ax	; dx:bx = linear
  2648 0000098F 87D3                    	xchg dx, bx	; bx:dx = linear
  2649 00000991 58                      	pop ax		; al = next character
  2650 00000992 C3                      	retn
  2651                                  
  2652                                  .error:
  2653 00000993 F9                      	stc
  2654 00000994 C3                      	retn
  2655                                  
  2656                                  
  2657                                  %if !_LOADER
  2658                                  		; INP:	word [reg_cs]
  2659                                  		;	(d)word [reg_eip]
  2660                                  		;	dword [tpg_possible_breakpoint]
  2661                                  		;	[internalflags2] & dif2_tpg_have_bp
  2662                                  		; OUT:	CY if invalid address
  2663                                  		;	NC if address is valid,
  2664                                  		;	 dx:ax = linear address
  2665                                  		; CHG:	edx, ax, ecx, bx
  2666                                  		; STT:	ds = ss = debugger data selector
  2667                                  get_cseip_of_possible_breakpoint:
  2668 00000995 A1[0000]                	mov ax, [tpg_possible_breakpoint]
  2669 00000998 8B16[0200]              	mov dx, [tpg_possible_breakpoint + 2]
  2670                                  			; dx:ax = stored possible breakpoint address
  2671 0000099C F606[0100]01            	testopt [internalflags2], dif2_tpg_have_bp
  2672 000009A1 7511                    	jnz .retn	; (NC) if already stored -->
  2673 000009A3 E810FF                  	call get_cseip_minus_1_linear
  2674                                  			; dx:ax = linear address at cs:(e)ip - 1
  2675 000009A6 720C                    	jc .retn	; (CY) if getlinear failed -->
  2676 000009A8 A3[0000]                	mov [tpg_possible_breakpoint], ax
  2677 000009AB 8916[0200]              	mov [tpg_possible_breakpoint + 2], dx
  2678                                  			; store for later use
  2679 000009AF 800E[0100]01            	setopt [internalflags2], dif2_tpg_have_bp
  2680                                  			; (NC)
  2681                                  .retn:
  2682 000009B4 C3                      	retn
  2683                                  
  2684                                  
  2685                                  %if _PM
  2686                                  
  2687                                  ; DEBUGX: when a mode switch from PM to RM did occur in the debuggee,
  2688                                  ; breakpoint addresses in non-RM address space are unreachable.
  2689                                  ; To enable the debugger to reset the breakpoints, it has to switch
  2690                                  ; temporarily to PM. (In DEBUG/X 1.19, a switch from RM to PM in the
  2691                                  ; debuggee will temporarily switch the debugger back to RM too. We
  2692                                  ; handle this case without a switch as the linear RM address can be
  2693                                  ; accessed directly in PM, assuming that the DPMI hosts linear-to-
  2694                                  ; physical mapping for the RM address space is the same as the one
  2695                                  ; we get in PM.)
  2696                                  
  2697                                  ; (To use mode switching in any case, the format the breakpoints are
  2698                                  ; stored in needs to be modified. Additionally, the mode switching
  2699                                  ; needs to be done elsewhere instead of in getsegmented. resetmode
  2700                                  ; can be used as is, even if a mode switch from PM to RM occured.)
  2701                                  
  2702                                  switchmode:
  2703                                  ;--- raw switch:
  2704                                  ;--- si:e/di: new cs:e/ip
  2705                                  ;--- dx:e/bx: new ss:e/sp
  2706                                  ;--- ax:      new ds
  2707                                  ;--- cx:      new es
  2708 000009B5 6631DB                  _386	xor ebx, ebx		; clear ebxh
  2709 000009B8 89E3                    	mov bx, sp
  2710 000009BA 6631FF                  _386	xor edi, edi		; clear edih
  2711 000009BD BF[E409]                	mov di, .back_after_switch
  2712 000009C0 E8(0000)                	call ispm
  2713 000009C3 740F                    	jz .pm
  2714                                  .r86m:
  2715                                  d4	call d4message
  2716                                  d4	asciz "In switchmode.r86m",13,10
  2717 000009C5 A1[0000]                	mov ax, [dssel]		; switch rm -> pm
  2718 000009C8 8B36[0000]              	mov si, [code_sel]
  2719 000009CC 89C2                    	mov dx, ax
  2720 000009CE 89C1                    	mov cx, ax
  2721 000009D0 FF2E[0000]              	jmp far [dpmi_rm2pm]
  2722                                  .pm:
  2723                                  d4	call d4message
  2724                                  d4	asciz "In switchmode.pm",13,10
  2725 000009D4 A1[0000]                	mov ax, [pspdbg]	; switch pm -> rm
  2726 000009D7 8B36[0000]              	mov si, [code_seg]
  2727 000009DB 89C2                    	mov dx, ax
  2728 000009DD 89C1                    	mov cx, ax
  2729 000009DF 66                      	_386_o32	; jmp far dword [dpmi_pm2rm]
  2730 000009E0 FF2E[0000]              	jmp far [dpmi_pm2rm]
  2731                                  
  2732                                  .back_after_switch:
  2733 000009E4 8036[0000]02            	xor byte [pm_2_86m_0], 2
  2734 000009E9 8036[0100]08            	xoropt [internalflags], protectedmode
  2735                                  d4	call d4message
  2736                                  d4	asciz "In switchmode.back_after_switch",13,10
  2737 000009EE C3                      	retn
  2738                                  
  2739                                  
  2740                                  		; INP:	al = direction, 0 = save state, 1 = restore state
  2741                                  		;	[auxbuff] = state buffer
  2742                                  		;	ES = debugger data selector
  2743                                  		; CHG:	edi
  2744                                  sr_state:
  2745 000009EF F606[0200]20            	testopt [internalflags], switchbuffer
  2746 000009F4 741B                    	jz .return		; no need to call -->
  2747 000009F6 66                      	_386_o32	; xor edi, edi
  2748 000009F7 31FF                    	xor di, di
  2749 000009F9 E8(0000)                	call ispm
  2750 000009FC 740A                    	jz .pm
  2751                                  .r86m:
  2752                                  d4	call d4message
  2753                                  d4	asciz "In sr_state.r86m",13,10
  2754 000009FE 8E06[0200]              	mov es, word [auxbuff_segorsel + soaSegment]
  2755 00000A02 FF1E[0000]              	call far [dpmi_rmsav]
  2756 00000A06 EB09                    	jmp .return
  2757                                  
  2758                                  .pm:
  2759                                  d4	call d4message
  2760                                  d4	asciz "In sr_state.pm",13,10
  2761 00000A08 8E06[0400]              	mov es, word [auxbuff_segorsel + soaSelector]
  2762 00000A0C 66                      	_386_o32	; call far dword [dpmi_pmsav]
  2763 00000A0D FF1E[0000]              	call far [dpmi_pmsav]
  2764                                  .return:
  2765 00000A11 16                      	push ss
  2766 00000A12 07                      	pop es
  2767 00000A13 C3                      	retn
  2768                                  
  2769                                  
  2770                                  		; INP:	[internalflags] & modeswitched
  2771                                  		; OUT:	flag cleared, mode switched back if had been switched
  2772                                  		;	EI
  2773                                  		; CHG:	- (not even flags!)
  2774                                  		; STT:	es = ds = ss = gs = fs = debugger data segment/selector
  2775                                  		;
  2776                                  		; Switches back to RM if a mode switch to PM was done by getsegmented.
  2777                                  		; Does nothing otherwise. (Can be called multiple times.)
  2778                                  resetmode: section_of_function
  2779 00000A14 9C                      	pushf
  2780 00000A15 F606[0200]08            	testopt [internalflags], modeswitched	; switched mode previously ?
  2781 00000A1A 741A                    	jz .return		; no -->
  2782                                  d4	call d4message
  2783                                  d4	asciz "In resetmode (actually resetting)",13,10
  2784                                  subcpu 286
  2785 00000A1C 66                      	_386_o32
  2786 00000A1D 60                      	pusha
  2787 00000A1E E894FF                  	call switchmode 	; switch back to the mode we were entered in (RM)
  2788 00000A21 B001                    	mov al, 1
  2789 00000A23 E8C9FF                  	call sr_state		; restore state
  2790 00000A26 E8F90D                  	call handle_mode_changed		; ! called with flag set
  2791 00000A29 8026[0200]F7            	clropt [internalflags], modeswitched	; reset the flag
  2792 00000A2E 16                      _386	push ss
  2793 00000A2F 0FA9                    _386	pop gs
  2794 00000A31 16                      _386	push ss
  2795 00000A32 0FA1                    _386	pop fs
  2796 00000A34 66                      	_386_o32
  2797 00000A35 61                      	popa
  2798                                  subcpureset
  2799                                  .return:
  2800 00000A36 9D                      	popf
  2801 00000A37 FB                      	sti
  2802 00000A38 C3                      	retn
  2803                                  %endif
  2804                                  %endif	; !_LOADER
  2805                                  
  2806                                  		; INP:	dx:ax = linear address
  2807                                  		; OUT:	CY if inaccessible
  2808                                  		;	NC if accessible,
  2809                                  		;	 bx:(e)dx = segment:offset or selector:offset address
  2810                                  		;	 A temporary mode switch from RM to PM might have occured.
  2811                                  		;	 This has to be reset by calling resetmode.
  2812                                  		; CHG:	(e)ax, (e)bx, (e)dx, fs, gs
  2813                                  		; STT:	es = ds = ss = our segment/selector
  2814                                  		;
  2815                                  		; It is assumed that only one byte needs to be accessed.
  2816                                  		; (A workaround to access multiple bytes would be to access each
  2817                                  		;  byte separately and call this function for each of the bytes.)
  2818                                  		;
  2819                                  		; The TSR command code assumes that getsegmented.pm does not switch
  2820                                  		; modes and that it will return an offset in (e)dx that allows
  2821                                  		; 16-bit access. Adjust that code if either is no longer true.
  2822                                  		;
  2823                                  		; This is often used in conjunction with writemem or
  2824                                  		;  readmem. Refer to debug.asm for those. Note that
  2825                                  		;  they will decide whether to use edx or dx depending
  2826                                  		;  on the segment limit of the selector returned in
  2827                                  		;  bx. Currently edxh is always zero so it doesn't
  2828                                  		;  matter whether writemem or readmem choose a32 or
  2829                                  		;  a16 addressing.
  2830                                  getsegmented: section_of_function
  2831                                  %if _DEBUG1
  2832                                  	push bx
  2833                                  	push cx
  2834                                  	mov bx, test_records_getSegmented
  2835                                  	call handle_test_case_multiple_16
  2836                                  	pop cx
  2837                                  	pop bx
  2838                                  	jnc @F
  2839                                  	; stc			; (already CY if the conditional didn't jump)
  2840                                  	retn
  2841                                  
  2842                                  @@:
  2843                                  %endif
  2844                                  .do_not_use_test:
  2845                                  
  2846                                  %if _PM
  2847 00000A39 E8(0000)                	call ispm
  2848 00000A3C 7520                    	jnz .rm
  2849                                  .pm:
  2850 00000A3E 51                      	push cx
  2851 00000A3F 8B1E[0000]              	mov bx, word [scratchsel]
  2852 00000A43 92                      	xchg ax, dx
  2853 00000A44 91                      	xchg ax, cx		; cx:dx = linear address
  2854 00000A45 B80700                  	mov ax, 0007h
  2855 00000A48 CD31                    	int 31h			; set base to the address
  2856 00000A4A 59                      	pop cx
  2857 00000A4B 7248                    	jc .invalid
  2858                                   %if 1
  2859 00000A4D 51                      	push cx
  2860 00000A4E B80800                  	mov ax, 0008h
  2861 00000A51 31C9                    	xor cx, cx
  2862 00000A53 31D2                    	xor dx, dx
  2863 00000A55 CD31                    	int 31h			; set limit to zero (access to one byte only)
  2864 00000A57 59                      	pop cx
  2865 00000A58 723B                    	jc .invalid
  2866                                   %endif
  2867 00000A5A 66                      	_386_o32	; xor edx, edx
  2868 00000A5B 31D2                    	xor dx, dx		; bx:(e)dx = selector:offset (using scratchsel with the address as base)
  2869 00000A5D C3                      	retn			; (NC)
  2870                                  %endif
  2871                                  .rm:
  2872 00000A5E 83FA10                  	cmp dx, byte 10h	; check for address space
  2873 00000A61 7249                    	jb .nothma		; below HMA, normal access -->
  2874 00000A63 7432                    	je .checkhma		; possibly in HMA -->
  2875                                  .nonrmspace:			; above HMA
  2876                                  %if _PM
  2877                                  		; It's a PM address but we are in RM.
  2878 00000A65 F606[0200]04            	testopt [internalflags], canswitchmode
  2879 00000A6A 7429                    	jz .invalid		; can't switch to PM -->
  2880                                  .switchmodes:
  2881 00000A6C 66                      	_386_o32
  2882 00000A6D 56                      	push si
  2883 00000A6E 66                      	_386_o32
  2884 00000A6F 57                      	push di
  2885 00000A70 66                      	_386_o32
  2886 00000A71 51                      	push cx
  2887 00000A72 66                      	_386_o32
  2888 00000A73 55                      	push bp
  2889 00000A74 52                      	push dx
  2890 00000A75 50                      	push ax
  2891                                  d4	call d4message
  2892                                  d4	asciz "In getsegmented.switchmodes (switching to access memory beyond 1088 KiB)",13,10
  2893 00000A76 E8830E                  	call remember_mode
  2894 00000A79 800E[0200]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  2895 00000A7E B000                    	mov al, 0
  2896 00000A80 E86CFF                  	call sr_state		; save state
  2897 00000A83 E82FFF                  	call switchmode 	; switch to PM
  2898 00000A86 E8990D                  	call handle_mode_changed		; ! called with flag set
  2899 00000A89 58                      	pop ax
  2900 00000A8A 5A                      	pop dx
  2901 00000A8B 66                      	_386_o32
  2902 00000A8C 5D                      	pop bp
  2903 00000A8D 66                      	_386_o32
  2904 00000A8E 59                      	pop cx
  2905 00000A8F 66                      	_386_o32
  2906 00000A90 5F                      	pop di
  2907 00000A91 66                      	_386_o32
  2908 00000A92 5E                      	pop si
  2909 00000A93 EBA9                    	jmp .pm
  2910                                  
  2911                                  .invalid:			; the address is inaccessible
  2912                                  %endif
  2913 00000A95 F9                      	stc
  2914 00000A96 C3                      	retn
  2915                                  
  2916                                  .checkhma:
  2917 00000A97 83F8F0                  	cmp ax, -10h		; valid offset for HMA ?
  2918 00000A9A 73C9                    	jae .nonrmspace		; no, above HMA -->
  2919 00000A9C F606[0100]20            	testopt [internalflags], debuggerA20	; A20 on, HMA accessible ?
  2920 00000AA1 74C2                    	jz .nonrmspace		; no, treat as above HMA (DEBUGX) -->
  2921 00000AA3 BBFFFF                  	mov bx, 0FFFFh		; the HMA must always be addressed by segment FFFFh
  2922 00000AA6 83C010                  	add ax, byte 10h	; and the offset is always at least 0010h (FFFFh:0010h = 00100000h)
  2923                                  		; (NC because we checked that this won't overflow)
  2924 00000AA9 92                      	xchg ax, dx		; bx:dx = segment:offset
  2925 00000AAA EB11                    	jmp .zero_edxh
  2926                                  
  2927                                  .nothma:
  2928 00000AAC 51                      	push cx
  2929 00000AAD B104                    	mov cl, 4
  2930 00000AAF D3CA                    	ror dx, cl		; dx (high 4 bits) = high 4 bits of segment
  2931 00000AB1 89C3                    	mov bx, ax
  2932 00000AB3 D3EB                    	shr bx, cl		; bx = low 12 bits of segment
  2933 00000AB5 09DA                    	or dx, bx		; dx = segment
  2934 00000AB7 83E00F                  	and ax, byte 0Fh	; ax = low 4 bits of linear, used as offset (NC)
  2935 00000ABA 92                      	xchg ax, dx
  2936 00000ABB 93                      	xchg ax, bx		; bx:dx = segment:offset
  2937 00000ABC 59                      	pop cx
  2938                                  .zero_edxh:
  2939 00000ABD 660FB7D2                _386_PM	movzx edx, dx
  2940 00000AC1 C3                      	retn
  2941                                  
  2942                                  
  2943                                  %if !_LOADER
  2944                                  		; T command - Trace.
  2945                                  tt:
  2946                                  %if _TEST_HELP_FILE
  2947                                  	dec si
  2948                                  	dec si
  2949                                  	mov dx, msg.testhelp
  2950                                  	call isstring?
  2951                                  	je testhelpfile
  2952                                  	inc si
  2953                                  	lodsb
  2954                                  %endif
  2955                                  
  2956 00000AC2 8A64FE                  	mov ah, byte [si - 2]
  2957 00000AC5 80E4DF                  	and ah, TOUPPER
  2958 00000AC8 80FC54                  	cmp ah, 'T'
  2959 00000ACB 7508                    	jne @F
  2960 00000ACD 88C4                    	mov ah, al
  2961 00000ACF 80E4DF                  	and ah, TOUPPER
  2962 00000AD2 80FC4D                  	cmp ah, 'M'
  2963                                  @@:
  2964 00000AD5 7544                    	jne isnotmodeset
  2965 00000AD7 E8(0000)                	call skipcomma
  2966 00000ADA E8(0000)                	call iseol?
  2967 00000ADD 7418                    	je ismodeget
  2968 00000ADF E8(0000)[0000]          	nearcall getexpression
  2969 00000AE4 E8(0000)                	call chkeol		; expect end of line here
  2970 00000AE7 09DA                    	or dx, bx
  2971 00000AE9 7507                    	jnz .set		; selected nonzero -->
  2972                                  .clear:				; selected zero
  2973 00000AEB 8026[0000]FD            	clropt [options], traceints
  2974 00000AF0 EB05                    	jmp short .get
  2975                                  .set:
  2976 00000AF2 800E[0000]02            	setopt [options], traceints
  2977                                  .get:
  2978                                  ismodeget:
  2979 00000AF7 B030                    	mov al, '0'
  2980 00000AF9 BE[0000]                	mov si, tmode0
  2981 00000AFC F606[0000]02            	testopt [options], traceints
  2982 00000B01 7404                    	jz .zero
  2983 00000B03 40                      	inc ax
  2984 00000B04 BE[0000]                	mov si, tmode1
  2985                                  .zero:
  2986 00000B07 A2[0000]                	mov byte [tmodev], al
  2987 00000B0A BF[0000]                	mov di, line_out
  2988 00000B0D 56                      	push si
  2989 00000B0E BE[0000]                	mov si, tmodes
  2990 00000B11 E8(0000)                	call showstring
  2991 00000B14 5E                      	pop si
  2992 00000B15 E8(0000)                	call showstring
  2993 00000B18 E9(0000)                	jmp putsline_crlf
  2994                                  
  2995                                  isnotmodeset:
  2996                                  %if _TSR && (_APPLICATION || _DEVICE)
  2997 00000B1B 80FC53                  	cmp ah, 'S'
  2998 00000B1E 750D                    	jne @F
  2999 00000B20 50                      	push ax
  3000 00000B21 8A04                    	mov al, byte [si]
  3001 00000B23 24DF                    	and al, TOUPPER
  3002 00000B25 3C52                    	cmp al, 'R'
  3003 00000B27 58                      	pop ax
  3004 00000B28 7503E95A02              	je tsr
  3005                                  @@:
  3006                                  %endif
  3007                                  
  3008                                  %if _RH
  3009 00000B2D E8(0000)                	call enable_rh
  3010                                  %endif
  3011                                  
  3012                                  %if _TTEST
  3013 00000B30 50                      	push ax
  3014 00000B31 80FC54                  	cmp ah, 'T'
  3015 00000B34 7516                    	jne @F
  3016 00000B36 8B04                    	mov ax, word [si]
  3017 00000B38 25DFDF                  	and ax, TOUPPER_W
  3018 00000B3B 3D4553                  	cmp ax, "ES"
  3019 00000B3E 750C                    	jne @F
  3020 00000B40 8A4402                  	mov al, byte [si + 2]
  3021 00000B43 24DF                    	and al, TOUPPER
  3022 00000B45 3C54                    	cmp al, 'T'
  3023 00000B47 7503E9C000              	je ttestcmd
  3024                                  @@:
  3025 00000B4C 58                      	pop ax
  3026                                  %endif
  3027                                  
  3028 00000B4D 8026[0300]F7            	clropt [internalflags], tt_p
  3029 00000B52 80FC50                  	cmp ah, 'P'
  3030 00000B55 7506                    	jne @F
  3031 00000B57 AC                      	lodsb
  3032 00000B58 800E[0300]08            	setopt [internalflags], tt_p
  3033                                  @@:
  3034                                  tt0:
  3035                                  %if _RH
  3036 00000B5D E8(0000)                	call enable_rh
  3037                                  %endif
  3038 00000B60 C706[0000][5D0B]        	mov word [lastcmd], tt0
  3039 00000B66 8026[0100]EF            	clropt [internalflags2], dif2_is_pp
  3040 00000B6B E8630E                  	call parse_pt		; process arguments
  3041                                  
  3042                                  		; Do it <BX:CX=count> times.
  3043                                  tt1:
  3044 00000B6E 53                      	push bx
  3045 00000B6F 51                      	push cx
  3046                                  
  3047 00000B70 F606[0300]08            	testopt [internalflags], tt_p
  3048 00000B75 744A                    	jz .not_p
  3049                                  
  3050                                  %if _PM
  3051 00000B77 E89AFE                  	call resetmode
  3052                                  %endif
  3053 00000B7A BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
  3054 00000B7D 8B1E[0000]              	mov bx, word [reg_cs]
  3055 00000B81 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
  3056 00000B82 8B36[0000]              	mov si, word [reg_eip]
  3057                                  .pp2:
  3058 00000B86 E8CB0A                  	call pp16		; get next instruction byte into AL
  3059 00000B89 BF[0000]                	mov di, ppbytes
  3060 00000B8C B9[0000]                	mov cx, PPLEN_ONLY_STRING
  3061                                  %if _SYMBOLIC
  3062                                  	mov byte [pp_instruction], al
  3063                                  %endif
  3064 00000B8F F2AE                    	repne scasb
  3065 00000B91 752E                    	jne .not_p		; if not one of these -->
  3066                                  %if _LINK_COMPAT
  3067 00000B93 8A85[FFFF]              	mov al,byte [word di+PPLEN-1]; get corresponding byte in ppinfo
  3068                                  %else
  3069                                  	mov al,byte [di+PPLEN-1]; get corresponding byte in ppinfo
  3070                                  %endif
  3071 00000B97 A880                    	test al, PP_PREFIX	; prefix ?
  3072 00000B99 740E                    	jz .pp3			; no -->
  3073 00000B9B 08C6                    	or dh, al		; set the OSIZE or ASIZE flags if either of these
  3074                                  			; Note:	Multiple OSIZE in a 16-bit cs do not toggle
  3075                                  			;	between decoding as O32 and O16, they're always
  3076                                  			;	decoded as O32. The same is true for A32, and
  3077                                  			;	in a 32-bit cs for O16 and A16.
  3078 00000B9D FECA                    	dec dl
  3079 00000B9F 75E5                    	jnz .pp2		; if not out of bytes -->
  3080 00000BA1 BA[0000]                	mov dx, msg.warnprefix
  3081 00000BA4 E8(0000)                	call putsz
  3082 00000BA7 EB18                    	jmp .not_p
  3083                                  
  3084                                  		; A repeatable string instruction is to be decoded.
  3085                                  		; Finish the decoding and skip the appropriate number
  3086                                  		; of opcode bytes.
  3087                                  .pp3:
  3088 00000BA9 E84906                  _386_PM	call pp_fix32bitflags
  3089 00000BAC A847                    	test al, PP_VARSIZ | PP_SIZ_MASK
  3090 00000BAE 7403E9(0000)            	jnz error
  3091                                  %if 0
  3092                                  	test al, PP_VARSIZ	; different opcode length depends on OSIZE ?
  3093                                  	jz .ignoreosize		; no -->
  3094                                  	and dh, 2
  3095                                  	add al, dh
  3096                                  .ignoreosize:
  3097                                  	and ax, PP_SIZ_MASK
  3098                                  _386_PM	movzx eax, ax		; clear high word (in case it counts)
  3099                                  	_386_PM_o32	; add esi, eax
  3100                                  	add si, ax
  3101                                  %endif
  3102                                  ; pp10:
  3103                                  %if _SYMBOLIC
  3104                                  	call pp3_check_symhints
  3105                                  	jc .not_p		; trace -->
  3106                                  %endif
  3107                                  	; jmp short pp11	; we have a skippable instruction here
  3108                                  ; pp11:
  3109 00000BB3 E8(0000)                _386_PM	call resetmode_and_test_d_b_bit
  3110 00000BB6 7504                    _386_PM	jnz .32			; full 32-bit offset valid -->
  3111 00000BB8 660FB7F6                _386_PM	movzx esi, si		; clear high word here
  3112                                  .32:
  3113 00000BBC E8FF09                  	call proceedbreakpoint	; run until the breakpoint is hit
  3114                                  		; This call might return modeswitched.
  3115 00000BBF EB03                    	jmp short @F
  3116                                  
  3117                                  .not_p:
  3118 00000BC1 E84B04                  	call traceone		; call common code
  3119                                  @@:
  3120 00000BC4 7303E90704              	jc unexpectedinterrupt	; an unexpected interrupt occured -->
  3121                                  %if _BREAKPOINTS
  3122 00000BC9 BA0000                  	mov dx, 0		; do not skip WHILE
  3123 00000BCC 7416                    	jz @F			; (breakpoint after instruction was hit)
  3124                                  
  3125                                  		; bb breakpoint was hit. dumpregs, then return
  3126 00000BCE E8C700                  	call handle_bb_hit_pass_match
  3127 00000BD1 7204                    	jc .actual_hit		; actual match ? -->
  3128 00000BD3 741A                    	jz tt2.nodump		; non-silent mode ? -->
  3129 00000BD5 EB0D                    	jmp tt2			; silent mode -->
  3130                                  
  3131                                  .actual_hit:
  3132                                  %if _PM
  3133 00000BD7 E83AFE                  	call resetmode
  3134                                  %endif
  3135 00000BDA E8D2F7                  	call put_deferred_message_silent
  3136 00000BDD E8FA07                  	call dumpregs_extended_silent
  3137 00000BE0 59                      	pop cx
  3138 00000BE1 5B                      	pop bx			; (discard counter)
  3139 00000BE2 EB1E                    	jmp @FF
  3140                                  @@:
  3141                                  %endif
  3142                                  tt2:
  3143 00000BE4 52                      	push dx
  3144                                  %if _PM
  3145 00000BE5 E82CFE                  	call resetmode
  3146                                  %endif
  3147 00000BE8 E8C4F7                  	call put_deferred_message_silent
  3148 00000BEB E8EC07                  	call dumpregs_extended_silent
  3149                                  				; dump registers
  3150 00000BEE 5A                      	pop dx			; preserve skip WHILE flag
  3151                                  .nodump:
  3152                                  
  3153 00000BEF E85800                  	call tt_handle_while
  3154 00000BF2 59                      	pop cx
  3155 00000BF3 5B                      	pop bx
  3156                                  
  3157 00000BF4 83E901                  	sub cx, 1
  3158 00000BF7 83DB00                  	sbb bx, 0		; decrement loop counter
  3159                                  
  3160 00000BFA 85DB                    	test bx, bx
  3161 00000BFC 750B                    	jnz tt1_jmp		; loop -->
  3162 00000BFE 85C9                    	test cx, cx
  3163 00000C00 7507                    	jnz tt1_jmp		; loop -->
  3164                                  
  3165                                  @@:
  3166                                  %if _PM
  3167 00000C02 E80FFE                  	call resetmode
  3168                                  %endif
  3169 00000C05 E8(0000)                	call silence_dump
  3170                                  
  3171 00000C08 C3                      	retn
  3172                                  
  3173                                  tt1_jmp:
  3174 00000C09 E962FF                  	jmp tt1
  3175                                  
  3176                                  
  3177                                  %if _TTEST
  3178                                  ttestcmd:
  3179 00000C0C 58                      	pop ax
  3180 00000C0D 46                      	inc si
  3181 00000C0E 46                      	inc si
  3182 00000C0F 46                      	inc si
  3183 00000C10 E8(0000)                	call skipwhite
  3184                                  
  3185                                  .tt0:
  3186 00000C13 C706[0000][130C]        	mov word [lastcmd], .tt0
  3187 00000C19 8026[0100]EF            	clropt [internalflags2], dif2_is_pp
  3188 00000C1E E8B00D                  	call parse_pt		; process arguments
  3189                                  
  3190                                  		; Do it <BX:CX=count> times.
  3191                                  .tt1:
  3192 00000C21 53                      	push bx
  3193 00000C22 51                      	push cx
  3194                                  
  3195                                  .tt2:
  3196                                  %if _PM
  3197 00000C23 E8EEFD                  	call resetmode
  3198                                  %endif
  3199 00000C26 E886F7                  	call put_deferred_message_silent
  3200 00000C29 E8AE07                  	call dumpregs_extended_silent
  3201                                  				; dump registers
  3202                                  .nodump:
  3203                                  
  3204 00000C2C 31D2                    	xor dx, dx
  3205 00000C2E E81900                  	call tt_handle_while
  3206 00000C31 59                      	pop cx
  3207 00000C32 5B                      	pop bx
  3208                                  
  3209 00000C33 83E901                  	sub cx, 1
  3210 00000C36 83DB00                  	sbb bx, 0		; decrement loop counter
  3211                                  
  3212 00000C39 85DB                    	test bx, bx
  3213 00000C3B 750B                    	jnz .tt1_jmp		; loop -->
  3214 00000C3D 85C9                    	test cx, cx
  3215 00000C3F 7507                    	jnz .tt1_jmp		; loop -->
  3216                                  
  3217                                  @@:
  3218                                  %if _PM
  3219 00000C41 E8D0FD                  	call resetmode
  3220                                  %endif
  3221 00000C44 E8(0000)                	call silence_dump
  3222                                  
  3223 00000C47 C3                      	retn
  3224                                  
  3225                                  .tt1_jmp:
  3226 00000C48 EBD7                    	jmp .tt1
  3227                                  %endif
  3228                                  
  3229                                  
  3230                                  		; INP:	dx = nonzero if to bypass while condition
  3231                                  tt_handle_while:
  3232 00000C4A 85D2                    	test dx, dx
  3233 00000C4C 753F                    	jnz @F
  3234 00000C4E F606[0300]04            	testopt [internalflags], tt_while
  3235 00000C53 7438                    	jz @F
  3236                                  
  3237                                  %if _PM
  3238 00000C55 E8BCFD                  	call resetmode
  3239                                  %endif
  3240 00000C58 E83300                  	call .point_to_condition
  3241                                  				; dx = si -> line_out with condition
  3242 00000C5B FF36[0000]              	push word [rc]
  3243 00000C5F 8F06[0000]              	pop word [priorrc]
  3244 00000C63 AC                      	lodsb
  3245 00000C64 E8(0000)[0000]          	nearcall getexpression	; parse stored expression
  3246 00000C69 E8(0000)                	call chkeol
  3247 00000C6C E8(0000)[0000]          	nearcall toboolean	; get boolean
  3248 00000C71 85D2                    	test dx, dx		; true ?
  3249 00000C73 7518                    	jnz @F			; yes, continue -->
  3250                                  
  3251 00000C75 E8(0000)                	call silence_dump
  3252                                  
  3253 00000C78 BA[0000]                	mov dx, msg.while_terminated_before
  3254 00000C7B E8(0000)                	call putsz
  3255 00000C7E E80D00                  	call .point_to_condition
  3256 00000C81 E8(0000)                	call putsz		; display condition
  3257 00000C84 BA[0000]                	mov dx, msg.while_terminated_after
  3258 00000C87 E8(0000)                	call putsz
  3259 00000C8A E9(0000)                	jmp cmd3
  3260                                  
  3261                                  @@:
  3262 00000C8D C3                      	retn
  3263                                  
  3264                                  
  3265                                  .point_to_condition:
  3266 00000C8E 16                      	push ss
  3267 00000C8F 07                      	pop es
  3268 00000C90 16                      	push ss
  3269 00000C91 1F                      	pop ds
  3270 00000C92 BE[0000]                	mov si, while_buffer
  3271 00000C95 89F2                    	mov dx, si
  3272 00000C97 C3                      	retn
  3273                                  
  3274                                  
  3275                                  		; INP:	cl = flags indicating what kind of bb match occurred
  3276                                  		;	 cl & 1 set if actual hit,
  3277                                  		;	 else cl & 2 set if pass match,
  3278                                  		;	 else it is a non-pass non-hit match
  3279                                  		;	(cl & 4 always set (indicates any bb match))
  3280                                  		;	 cl & 8 set if pp/tt breakpoint hit
  3281                                  		;	dword [ss:sp] = command repetition counter
  3282                                  		; OUT:	NC if pass match or non-pass non-hit match,
  3283                                  		;	 if pass match: deferred message output, dumpregs output
  3284                                  		;	 if cl & 8 set (pass/nonpass bb, tt/pp hit):
  3285                                  		;	  dx = 0
  3286                                  		;	  ZR if [internalflags] & tt_silent_mode clear
  3287                                  		;	  NZ if [internalflags] & tt_silent_mode set
  3288                                  		;	 if cl & 8 clear (pass/nonpass bb, no tt/pp hit):
  3289                                  		;	  ZR
  3290                                  		;	  dword [ss:sp] increased by 1
  3291                                  		;	  dx = 1 (indicates to skip WHILE condition)
  3292                                  		;	CY if actual hit (hit bb),
  3293                                  		;	 dx = 0
  3294                                  		;	ax = INP:cx
  3295                                  		; CHG:	dx, bx, cx, si, di, all high words, fs, gs
  3296                                  		; STT:	ds = es = ss
  3297                                  handle_bb_hit_pass_match:
  3298                                  d5	call d5message
  3299                                  d5	asciz "in handle_bb_hit_pass_match",13,10
  3300                                  
  3301 00000C98 91                      	xchg ax, cx
  3302                                  
  3303 00000C99 F606[0100]08            	testopt [internalflags2], dif2_bp_failure
  3304 00000C9E 756C                    	jnz .actual_hit		; after failure, handle as actual hit
  3305                                  
  3306 00000CA0 A801                    	test al, 1		; actual hit ?  else: non-hit, pass or non-pass
  3307 00000CA2 7568                    	jnz .actual_hit		; yes -->
  3308                                  
  3309 00000CA4 A802                    	test al, 2		; at least pass match ?
  3310 00000CA6 7418                    	jz .nonpassnonhit	; no -->
  3311                                  
  3312                                  .passnonhit:
  3313                                  
  3314                                  d5	call d5message
  3315                                  d5	asciz "bb pass non-hit",13,10
  3316                                  
  3317                                  %if _PM
  3318 00000CA8 E869FD                  	call resetmode
  3319                                  %endif
  3320                                  	; call put_deferred_message_loud
  3321 00000CAB BA[0000]                	mov dx, msg.empty_message
  3322 00000CAE 8716[0000]              	xchg dx, word [gg_deferred_message]
  3323 00000CB2 E8(0000)                	call putsz
  3324 00000CB5 BA[0000]                	mov dx, putsline
  3325 00000CB8 E801F7                  	call put_bb_deferred_message_calling_dx
  3326                                  
  3327 00000CBB 50                      	push ax
  3328                                  	; call dumpregs_extended_loud
  3329                                  				; (includes handle_serial_flags_ctrl_c)
  3330 00000CBC E8(0000)                	call dumpregs_extended
  3331 00000CBF 58                      	pop ax			; (preserve so the test al, 8 can use it)
  3332                                  .nonpassnonhit:
  3333 00000CC0 E82307                  	call handle_serial_flags_ctrl_c
  3334                                  
  3335                                  	; al & 4 always set
  3336                                  
  3337 00000CC3 8026[0000]E9            	clropt [internalflags2], 		dif2_gg_skip_non_cseip | dif2_gg_skip_cseip | dif2_gg_first_detected
  3339 00000CC8 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
  3340                                  
  3341 00000CCD FF36[0200]              	push word [gg_next_cseip_linear + 2]
  3342 00000CD1 FF36[0000]              	push word [gg_next_cseip_linear]
  3343 00000CD5 8F06[0000]              	pop word [gg_first_cseip_linear]
  3344 00000CD9 8F06[0200]              	pop word [gg_first_cseip_linear + 2]
  3345                                  
  3346 00000CDD A808                    	test al, 8		; not bb hit, is tt/pp hit ?
  3347 00000CDF 751C                    	jnz @FF			; yes -->
  3348                                  
  3349 00000CE1 F706[0000]8010          	testopt [internalflags2], dif2_is_pp | dif2_tpg_keep_proceed_bp, 1
  3350 00000CE7 7502                    	jnz @F
  3351 00000CE9 EB12                    	jmp @FF
  3352                                  
  3353                                  @@:
  3354                                  	lframe near
  3355                                  	lpar dword,	counter
  3356                                  	lpar_return
  3357 00000CEB 5589E5                  	lenter
  3358 00000CEE 83460401                	add word [bp + ?counter], 1
  3359 00000CF2 83560600                	adc word [bp + ?counter + 2], 0
  3360 00000CF6 5D                      	lleave
  3361 00000CF7 BA0100                  	mov dx, 1		; skip WHILE
  3362 00000CFA 38C0                    	cmp al, al		; (NC, ZR)
  3363 00000CFC C3                      	retn
  3364                                  
  3365                                  @@:
  3366 00000CFD 31D2                    	xor dx, dx		; no skip WHILE
  3367 00000CFF A802                    	test al, 2		; displayed pass point ?
  3368 00000D01 7503                    	jnz @F			; yes -->
  3369 00000D03 A8FF                    	test al, -1		; NC, NZ (do not skip dump)
  3370                                  		; al & 0Ch is set so this test is NZ
  3371 00000D05 C3                      	retn
  3372                                  
  3373                                  @@:
  3374 00000D06 F606[0300]10            	testopt [internalflags], tt_silent_mode
  3375                                  				; (NC, ZF is ZR if to skip dump)
  3376 00000D0B C3                      	retn
  3377                                  
  3378                                  .actual_hit:
  3379                                  d5	call d5message
  3380                                  d5	asciz "bb hit",13,10
  3381                                  
  3382 00000D0C 31D2                    	xor dx, dx		; no skip WHILE
  3383 00000D0E F9                      	stc
  3384 00000D0F C3                      	retn
  3385                                  
  3386                                  
  3387                                  %if _ATTACH
  3388                                  attach:
  3389                                   %if _BOOTLDR
  3390 00000D10 F606[0100]40            	testopt [internalflags], nodosloaded
  3391 00000D15 7403E9(0000)            	jnz error
  3392                                   %endif
  3393 00000D1A E8(0000)                	call skipwh0
  3394 00000D1D E8(0000)[0000]          	nearcall getword
  3395 00000D22 E8(0000)                	call chkeol
  3396 00000D25 F606[0200]40            	testopt [internalflags], tsrmode
  3397 00000D2A 750C                    	jnz @F			; resident -->
  3398 00000D2C BA[0000]                	mov dx, msg.notyettsr
  3399 00000D2F B81101                  	mov ax, 0111h
  3400                                  .specificerror:
  3401 00000D32 E8(0000)                	call setrc
  3402 00000D35 E9(0000)                	jmp putsz_error
  3403                                  
  3404                                  @@:
  3405                                   %if _PM
  3406 00000D38 E8(0000)                	call setes2dx
  3407                                   %else
  3408                                  	mov es, dx
  3409                                   %endif
  3410 00000D3B 26813E0000CD20          	cmp word [es:0], 20CDh
  3411 00000D42 7408                    	je @F
  3412 00000D44 BA[0000]                	mov dx, msg.invalidpsp
  3413 00000D47 B81201                  	mov ax, 0112h
  3414 00000D4A EBE6                    	jmp .specificerror
  3415                                  
  3416                                  @@:
  3417 00000D4C 2639161600              	cmp word [es:16h], dx
  3418 00000D51 7508                    	jne @F
  3419 00000D53 BA[0000]                	mov dx, msg.selfownedpsp
  3420 00000D56 B81301                  	mov ax, 0113h
  3421 00000D59 EBD7                    	jmp .specificerror
  3422                                  
  3423                                  @@:
  3424 00000D5B 06                      	push es
  3425 00000D5C 1F                      	pop ds
  3426 00000D5D 16                      	push ss
  3427 00000D5E 07                      	pop es
  3428 00000D5F BE0A00                  	mov si, TPIV
  3429 00000D62 BF[0000]                	mov di, psp22
  3430 00000D65 A5                      	movsw
  3431 00000D66 A5                      	movsw				; save Int22
  3432                                   %if _PM
  3433 00000D67 36A1[0000]              	mov ax, word [ss:pspdbg]
  3434                                   %else
  3435                                  	mov ax, ss			; => our process
  3436                                   %endif
  3437 00000D6B C744FC[F001]            	mov word [ si-4 ], int22
  3438 00000D70 8944FE                  	mov word [ si-2 ], ax		; set pspInt22 (required)
  3439 00000D73 BE1600                  	mov si, 16h
  3440 00000D76 A5                      	movsw				; save parent
  3441 00000D77 8944FE                  	mov word [ si-2 ], ax		; set pspParent
  3442 00000D7A 16                      	push ss
  3443 00000D7B 1F                      	pop ds
  3444 00000D7C 8026[0200]BF            	clropt [internalflags], tsrmode
  3445 00000D81 BA[0000]                	mov dx, msg.nowattached
  3446 00000D84 E9(0000)                	jmp putsz
  3447                                  %endif
  3448                                  
  3449                                  
  3450                                  %if _TSR && (_APPLICATION || _DEVICE)
  3451                                  tsr:
  3452                                   %if _BOOTLDR
  3453 00000D87 F606[0100]40            	testopt [internalflags], nodosloaded
  3454 00000D8C 7403E9(0000)            	jnz error
  3455                                   %endif
  3456 00000D91 E8(0000)                	call guard_re
  3457 00000D94 46                      	inc si
  3458 00000D95 AC                      	lodsb
  3459 00000D96 E8(0000)                	call chkeol
  3460 00000D99 F606[0200]40            	testopt [internalflags], tsrmode
  3461 00000D9E 7408                    	jz .try			; not yet resident -->
  3462 00000DA0 BA[0000]                	mov dx, msg.alreadytsr
  3463 00000DA3 B81401                  	mov ax, 0114h
  3464 00000DA6 EB5A                    	jmp .specificerror_es
  3465                                  .try:
  3466 00000DA8 8B16[0000]              	mov dx, word [pspdbe]
  3467 00000DAC 8B1E[0000]              	mov bx, word [pspdbg]
  3468 00000DB0 BF0A00                  	mov di, 0Ah
  3469                                  .loop:
  3470                                  %if _PM
  3471 00000DB3 89D1                    	mov cx, dx		; = original segment address
  3472 00000DB5 E8(0000)                	call ispm
  3473 00000DB8 7517                    	jnz .rm
  3474 00000DBA 53                      	push bx
  3475 00000DBB 89D0                    	mov ax, dx
  3476                                  [cpu 286]
  3477 00000DBD C1EA0C                  	shr dx, 12
  3478 00000DC0 C1E004                  	shl ax, 4		; shift to get a 32-bit linear address
  3479                                  __CPU__
  3480 00000DC3 E878FC                  	call getsegmented.pm	; set up selector for access
  3481                                  		; This call makes some assumptions:
  3482                                  		; - No mode switch occurs; we are still in PM.
  3483                                  		;    Currently none is performed from PM.
  3484                                  		; - (e)dx isn't larger than about FFD0h.
  3485                                  		;    Currently scratchsel with an offset of zero is returned.
  3486 00000DC6 E8(0000)                	call setrmlimit
  3487 00000DC9 89D7                    	mov di, dx		; -> PSP
  3488 00000DCB 89DA                    	mov dx, bx
  3489 00000DCD 5B                      	pop bx
  3490 00000DCE 83C70A                  	add di, byte 0Ah	; -> PSP termination vector
  3491                                  .rm:
  3492                                  %endif
  3493 00000DD1 8EC2                    	mov es, dx
  3494 00000DD3 268B450C                	mov ax, word [es:(di-0Ah)+16h]
  3495 00000DD7 40                      	inc ax
  3496 00000DD8 7422                    	jz .pspnotfound
  3497 00000DDA 48                      	dec ax
  3498 00000DDB 741F                    	jz .pspnotfound		; parent is invalid -->
  3499                                  %if _PM
  3500 00000DDD 39C8                    	cmp ax, cx
  3501                                  %else
  3502                                  	cmp ax, dx
  3503                                  %endif
  3504 00000DDF 741B                    	je .pspnotfound		; parent is the process itself -->
  3505 00000DE1 89C2                    	mov dx, ax
  3506 00000DE3 39D8                    	cmp ax, bx
  3507 00000DE5 75CC                    	jne .loop		; parent is not us -->
  3508 00000DE7 26813D[F001]            	cmp word [es:di], int22
  3509 00000DEC 7506                    	jne .psphooked
  3510 00000DEE 26395D02                	cmp word [es:di+2], bx
  3511 00000DF2 7416                    	je .found		; correct vector --> (otherwise: hooked)
  3512                                  .psphooked:
  3513 00000DF4 BA[0000]                	mov dx, msg.psphooked
  3514 00000DF7 B80F01                  	mov ax, 010Fh
  3515 00000DFA EB06                    	jmp short .specificerror_es
  3516                                  .pspnotfound:
  3517 00000DFC BA[0000]                	mov dx, msg.pspnotfound
  3518 00000DFF B81001                  	mov ax, 0110h
  3519                                  .specificerror_es:
  3520 00000E02 E8(0000)                	call setrc
  3521                                  .putsz_es:
  3522 00000E05 16                      	push ss
  3523 00000E06 07                      	pop es
  3524                                  .putsz:
  3525 00000E07 E9(0000)                	jmp putsz
  3526                                  
  3527                                  .found:
  3528 00000E0A BE[0000]                	mov si, psp22
  3529 00000E0D A5                      	movsw
  3530 00000E0E A5                      	movsw			; write our parent's vector
  3531 00000E0F 83C708                  	add di, 16h-(0Ah+4)
  3532 00000E12 A5                      	movsw			; write our parent
  3533 00000E13 800E[0200]40            	setopt [internalflags], tsrmode	; note that we are resident
  3534                                  %if _PM
  3535 00000E18 51                      	push cx
  3536                                  %else
  3537                                  	push es
  3538                                  %endif
  3539 00000E19 BA[0000]                	mov dx, msg.nowtsr1
  3540 00000E1C E8E6FF                  	call .putsz_es
  3541 00000E1F 58                      	pop ax
  3542 00000E20 BF[0000]                	mov di, line_out
  3543 00000E23 E8(0000)                	call hexword
  3544 00000E26 E8(0000)                	call putsline
  3545 00000E29 BF[0000]                	mov di, psp22
  3546 00000E2C 31C0                    	xor ax, ax
  3547 00000E2E AB                      	stosw
  3548 00000E2F AB                      	stosw
  3549 00000E30 AB                      	stosw			; clear our parent/int22 fields
  3550 00000E31 BA[0000]                	mov dx, msg.nowtsr2
  3551 00000E34 EBD1                    	jmp short .putsz
  3552                                  %endif
  3553                                  
  3554                                  
  3555                                  		; INP:	dx -> message, zero-terminated
  3556                                  		; CHG:	-
  3557                                  		; OUT:	message displayed or put into silent buffer
  3558                                  		; STT:	ds = es = ss = debugger data selector
  3559                                  putsz_silent:
  3560 00000E36 E81000                  	call silence_init
  3561 00000E39 E8(0000)                	call putsz		; print string
  3562                                  
  3563                                  silence_exit:
  3564 00000E3C F606[0300]10            	testopt [internalflags], tt_silent_mode
  3565 00000E41 7405                    	jz @F
  3566 00000E43 8026[0300]DF            	clropt [internalflags], tt_silence
  3567                                  @@:
  3568 00000E48 C3                      	retn
  3569                                  
  3570                                  
  3571                                  silence_init:
  3572 00000E49 F606[0300]10            	testopt [internalflags], tt_silent_mode
  3573 00000E4E 7405                    	jz @F
  3574 00000E50 800E[0300]20            	setopt [internalflags], tt_silence
  3575                                  @@:
  3576 00000E55 C3                      	retn
  3577                                  
  3578                                  
  3579                                  		; INP:	es:di -> behind message in line_out
  3580                                  		; CHG:	ax, bx, cx, dx
  3581                                  		; OUT:	message displayed or put into silent buffer
  3582                                  		; STT:	ds = es = ss = debugger data selector
  3583                                  putsline_silent:
  3584 00000E56 E8F0FF                  	call silence_init
  3585 00000E59 E8(0000)                	call putsline
  3586 00000E5C EBDE                    	jmp silence_exit
  3587                                  
  3588                                  
  3589                                  		; INP:	word [run_int]
  3590                                  		;	InDOS status
  3591                                  		; STT:	es = ds = ss
  3592                                  		; OUT:	dx -> last message
  3593                                  		;	message displayed
  3594                                  		; CHG:	ax, di
  3595                                  putrunint:
  3596                                  %if _DEBUG && _DEBUG_COND
  3597                                  	testopt [options6], opt6_debug_putrunint
  3598                                  	jz @F
  3599                                  	testopt [internalflags6], dif6_debug_mode
  3600                                  	jnz @F
  3601                                  	call reset_interrupts
  3602                                  	setopt [internalflags6], dif6_debug_mode
  3603                                  	setopt [options6], opt6_debug_mode
  3604                                  @@:
  3605                                  %endif
  3606                                  
  3607                                  %if _DEBUG
  3608                                   %if _DEBUG_COND
  3609                                  	testopt [internalflags6], dif6_debug_mode
  3610                                  	jz @F
  3611                                   %endif
  3612                                  	testopt [options6], opt6_debug_putrunint_early
  3613                                  	jz @F
  3614                                  	int3
  3615                                  	nop
  3616                                  @@:
  3617                                  %endif
  3618                                  
  3619                                  %if _AREAS_HOOK_SERVER
  3620 00000E5E 66                      	_386_PM_o32		; push ecx
  3621 00000E5F 51                      	push cx
  3622 00000E60 53                      	push bx
  3623 00000E61 66                      	_386_PM_o32		; push esi
  3624 00000E62 56                      	push si
  3625                                  
  3626 00000E63 A1[0000]                	mov ax, word [run_int]
  3627 00000E66 3D[0000]                	cmp ax, int1msg
  3628 00000E69 740F                    	je .end_j
  3629 00000E6B 3D[0000]                	cmp ax, int3msg
  3630 00000E6E 740A                    	je .end_j
  3631                                  %if _CATCHINT19
  3632 00000E70 3D[0000]                	cmp ax, int19msg
  3633 00000E73 7405                    	je .end_j
  3634                                  %endif
  3635 00000E75 3D[0000]                	cmp ax, progtrm
  3636 00000E78 7503                    	jne @F
  3637                                  .end_j:
  3638 00000E7A E92A01                  	jmp .end
  3639                                  
  3640                                  @@:
  3641 00000E7D 66                      	_386_PM_o32		; xor ecx, ecx
  3642 00000E7E 31C9                    	xor cx, cx
  3643 00000E80 E837FA                  	call get_cseip_ecx_linear
  3644 00000E83 89D3                    	mov bx, dx		; bx:ax = linear cs:eip
  3645 00000E85 16                      	push ss
  3646 00000E86 07                      	pop es
  3647 00000E87 BF[0000]                	mov di, ddebugareas
  3648 00000E8A 31C9                    	xor cx, cx
  3649                                  
  3650                                  .loop:
  3651                                  %if _PM
  3652 00000E8C 268B551A                	mov dx, word [es:di + areastrucNext + 2]
  3653 00000E90 268B7D18                	mov di, word [es:di + areastrucNext]
  3654 00000E94 E8(0000)                	call setes2dx
  3655                                  %else
  3656                                  	les di, [es:di + areastrucNext]
  3657                                  	mov dx, es
  3658                                  %endif
  3659 00000E97 3B16[0000]              	cmp dx, word [pspdbg]
  3660 00000E9B 7503E90701              	je .end
  3661                                  
  3662 00000EA0 52                      	push dx
  3663 00000EA1 57                      	push di
  3664 00000EA2 51                      	push cx
  3665 00000EA3 53                      	push bx
  3666 00000EA4 50                      	push ax
  3667                                  
  3668 00000EA5 57                      	push di
  3669 00000EA6 268B4D24                	mov cx, word [es:di + areastrucFunAmount]
  3670 00000EAA 268B7D26                	mov di, word [es:di + areastrucFunOffset]
  3671 00000EAE E36E                    	jcxz .noareafun
  3672                                  .loopareafun:
  3673 00000EB0 263B5D02                	cmp bx, word [es:di + areastrucfunLinear + 2]
  3674 00000EB4 7503                    	jne @F
  3675 00000EB6 263B05                  	cmp ax, word [es:di + areastrucfunLinear]
  3676                                  @@:
  3677 00000EB9 725E                    	jb .nextareafun
  3678                                  
  3679 00000EBB 263B5D06                	cmp bx, word [es:di + areastrucfunLinearEnd + 2]
  3680 00000EBF 7504                    	jne @F
  3681 00000EC1 263B4504                	cmp ax, word [es:di + areastrucfunLinearEnd]
  3682                                  @@:
  3683 00000EC5 7352                    	jae .nextareafun
  3684                                  
  3685 00000EC7 53                      	push bx
  3686 00000EC8 50                      	push ax
  3687 00000EC9 51                      	push cx
  3688 00000ECA 57                      	push di
  3689                                  
  3690 00000ECB 262B05                  	sub ax, word [es:di + areastrucfunLinear]
  3691 00000ECE 261B5D02                	sbb bx, word [es:di + areastrucfunLinear + 2]
  3692 00000ED2 7541                    	jnz .nextareafun_pop
  3693                                  
  3694 00000ED4 268B4D0A                	mov cx, word [es:di + areastrucfunListAmount]
  3695 00000ED8 51                      	push cx
  3696 00000ED9 268B7D08                	mov di, word [es:di + areastrucfunListOffset]
  3697 00000EDD F2AF                    	repne scasw
  3698 00000EDF 59                      	pop cx
  3699 00000EE0 7533                    	jne .nextareafun_pop
  3700 00000EE2 01C9                    	add cx, cx
  3701 00000EE4 4F                      	dec di
  3702 00000EE5 4F                      	dec di
  3703 00000EE6 01CF                    	add di, cx
  3704 00000EE8 6631C9                  _386_PM	xor ecx, ecx
  3705 00000EEB 268B0D                  	mov cx, word [es:di]
  3706 00000EEE 66                      	_386_PM_o32
  3707 00000EEF 8B36[0000]              	mov si, word [reg_esp]
  3708 00000EF3 66                      	_386_PM_o32
  3709 00000EF4 01CE                    	add si, cx
  3710 00000EF6 1E                      	push ds
  3711                                  %if _PM
  3712 00000EF7 8B1E[0000]              	mov bx, word [reg_ss]
  3713 00000EFB E8(0000)                	call test_d_b_bit
  3714 00000EFE 8EDB                    	mov ds, bx
  3715 00000F00 7401                    	jz .16
  3716                                  .32:
  3717 00000F02 67                      	_386_PM_a32
  3718                                  %else
  3719                                  	mov ds, word [reg_ss]
  3720                                  %endif
  3721                                  .16:
  3722 00000F03 AD                      	lodsw
  3723 00000F04 1F                      	pop ds
  3724                                  .gotfunction:
  3725 00000F05 5F                      	pop di
  3726 00000F06 59                      	pop cx
  3727 00000F07 5B                      	pop bx			; (discard)
  3728 00000F08 5B                      	pop bx
  3729                                  
  3730 00000F09 92                      	xchg dx, ax
  3731 00000F0A 8B1E[0000]              	mov bx, word [reg_cs]	; bx:dx = cs:ip
  3732 00000F0E E8D3F9                  	call getlinear_16bit	; dx:ax = linear
  3733 00000F11 89D3                    	mov bx, dx		; bx:ax = linear
  3734 00000F13 EB09                    	jmp .noareafun
  3735                                  
  3736                                  .nextareafun_pop:
  3737 00000F15 5F                      	pop di
  3738 00000F16 59                      	pop cx
  3739 00000F17 58                      	pop ax
  3740 00000F18 5B                      	pop bx
  3741                                  .nextareafun:
  3742 00000F19 83C70C                  	add di, AREASTRUCFUN_size
  3743 00000F1C E292                    	loop .loopareafun
  3744                                  .noareafun:
  3745 00000F1E 5F                      	pop di
  3746                                  
  3747 00000F1F 268B4D20                	mov cx, word [es:di + areastrucSubAmount]
  3748 00000F23 268B7D22                	mov di, word [es:di + areastrucSubOffset]
  3749 00000F27 E36F                    	jcxz .noareasub
  3750                                  .loopareasub:
  3751 00000F29 263B5D02                	cmp bx, word [es:di + areastrucsubLinear + 2]
  3752 00000F2D 7503                    	jne @F
  3753 00000F2F 263B05                  	cmp ax, word [es:di + areastrucsubLinear]
  3754                                  @@:
  3755 00000F32 725F                    	jb .nextareasub
  3756                                  
  3757 00000F34 263B5D06                	cmp bx, word [es:di + areastrucsubLinearEnd + 2]
  3758 00000F38 7504                    	jne @F
  3759 00000F3A 263B4504                	cmp ax, word [es:di + areastrucsubLinearEnd]
  3760                                  @@:
  3761 00000F3E 7353                    	jae .nextareasub
  3762                                  
  3763 00000F40 53                      	push bx
  3764 00000F41 50                      	push ax
  3765 00000F42 51                      	push cx
  3766 00000F43 57                      	push di
  3767                                  
  3768 00000F44 262B05                  	sub ax, word [es:di + areastrucsubLinear]
  3769 00000F47 261B5D02                	sbb bx, word [es:di + areastrucsubLinear + 2]
  3770 00000F4B 7542                    	jnz .nextareasub_pop
  3771                                  
  3772 00000F4D 89C2                    	mov dx, ax		; = ip
  3773 00000F4F 268B7508                	mov si, word [es:di + areastrucsubListOffset]
  3774 00000F53 268B4D0A                	mov cx, word [es:di + areastrucsubListAmount]
  3775                                  .looparea:
  3776 00000F57 26AD                    	es lodsw
  3777 00000F59 39C2                    	cmp dx, ax
  3778 00000F5B 26AD                    	es lodsw
  3779 00000F5D 722B                    	jb .nextarea
  3780 00000F5F 39C2                    	cmp dx, ax
  3781 00000F61 7327                    	jae .nextarea
  3782 00000F63 26AD                    	es lodsw
  3783 00000F65 89C3                    	mov bx, ax		; es:bx -> area message
  3784 00000F67 92                      	xchg ax, dx		; es:dx -> area message
  3785                                  
  3786                                  		; If we are displaying to a serial port then
  3787                                  		;  we assume that we are not sharing the output
  3788                                  		;  device with an areas hook client. Therefore
  3789                                  		;  we want to skip the initial linebreal in the
  3790                                  		;  areas message if there is one.
  3791                                  		; The linebreaks are intended to separate (shared)
  3792                                  		;  output from prior output of the code that caused
  3793                                  		;  the fault, eg interactive E mode prompt or
  3794                                  		;  partial disassembly output.
  3795 00000F68 26813F0D0A              	cmp word [es:bx], 13 | (10 << 8)
  3796                                  				; is it with an initial linebreak ?
  3797 00000F6D 7509                    	jne @F			; no -->
  3798 00000F6F F606[0000]10            	testopt [serial_flags], sf_use_serial
  3799 00000F74 7402                    	jz @F			; if not serial -->
  3800 00000F76 42                      	inc dx
  3801 00000F77 42                      	inc dx			; skip the linebreak
  3802                                  @@:
  3803 00000F78 06                      	 push es
  3804 00000F79 1F                      	 pop ds			; => our area hook client's data selector
  3805 00000F7A E8(0000)                	call putsz		; display ds:dx -> ASCIZ message
  3806 00000F7D 16                      	 push ss
  3807 00000F7E 1F                      	 pop ds			; reset ds
  3808 00000F7F 5F                      	pop di
  3809 00000F80 59                      	pop cx
  3810 00000F81 58                      	pop ax
  3811 00000F82 5B                      	pop bx
  3812                                  
  3813 00000F83 58                      	pop ax
  3814 00000F84 5B                      	pop bx
  3815 00000F85 59                      	pop cx
  3816 00000F86 5F                      	pop di
  3817 00000F87 5A                      	pop dx
  3818                                  
  3819 00000F88 EB1D                    	jmp .end
  3820                                  
  3821                                  .nextarea:
  3822 00000F8A 83C604                  	add si, 4
  3823 00000F8D E2C8                    	loop .looparea
  3824                                  
  3825                                  .nextareasub_pop:
  3826 00000F8F 5F                      	pop di
  3827 00000F90 59                      	pop cx
  3828 00000F91 58                      	pop ax
  3829 00000F92 5B                      	pop bx
  3830                                  .nextareasub:
  3831 00000F93 83C70C                  	add di, AREASTRUCSUB_size
  3832 00000F96 E291                    	loop .loopareasub
  3833                                  .noareasub:
  3834                                  
  3835                                  .next:
  3836 00000F98 58                      	pop ax
  3837 00000F99 5B                      	pop bx
  3838 00000F9A 59                      	pop cx
  3839 00000F9B 5F                      	pop di
  3840                                  %if _PM
  3841 00000F9C 5A                      	pop dx
  3842 00000F9D E8(0000)                	call setes2dx
  3843                                  %else
  3844                                  	pop es
  3845                                  %endif
  3846 00000FA0 E202                    	loop .loop_j
  3847 00000FA2 EB03                    	jmp .end
  3848                                  
  3849                                  .loop_j:
  3850 00000FA4 E9E5FE                  	jmp .loop
  3851                                  
  3852                                  .end:
  3853 00000FA7 66                      	_386_PM_o32		; pop esi
  3854 00000FA8 5E                      	pop si
  3855 00000FA9 5B                      	pop bx
  3856 00000FAA 66                      	_386_PM_o32		; pop ecx
  3857 00000FAB 59                      	pop cx
  3858                                  %endif
  3859 00000FAC 16                      	 push ss
  3860 00000FAD 07                      	 pop es
  3861                                  
  3862                                  .noarea:
  3863 00000FAE 8B16[0000]              	mov dx, word [run_int]
  3864 00000FB2 81FA[0000]              	cmp dx, progtrm
  3865 00000FB6 7515                    	jne .done
  3866                                  
  3867 00000FB8 B8FFFF                  	mov ax, -1
  3868 00000FBB E8(0000)                	call InDOS
  3869 00000FBE 7504                    	jnz .no_int21_4D
  3870                                  
  3871 00000FC0 B44D                    	mov ah, 4Dh
  3872 00000FC2 CD21                    	int 21h
  3873                                  .no_int21_4D:
  3874 00000FC4 A3[0000]                	mov word [usertermcode], ax
  3875 00000FC7 BF[0000]                	mov di, progexit
  3876 00000FCA E8(0000)                	call hexword
  3877                                  .done:
  3878 00000FCD E9(0000)                	jmp putsz
  3879                                  
  3880                                  
  3881                                  	usesection lDEBUG_DATA_ENTRY
  3881          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3882                                  %if _LINK_COMPAT
  3883                                  	align 16, db 0
  3884                                  %endif
  3885                                  
  3886                                  	align 2, db 0
  3887 00000000 0000                    usertermcode:	dw 0
  3888                                  	usesection lDEBUG_CODE
  3888          ------------------       note: usesection lDEBUG_CODE
  3889                                  
  3890                                  
  3891                                  		; Print message about unexpected interrupt, dump registers, and
  3892                                  		; end command. This code is also used by the G and P commands.
  3893                                  unexpectedinterrupt: section_of_function
  3894                                  %if _PM
  3895 00000FD0 E841FA                  	call resetmode
  3896                                  %endif
  3897 00000FD3 E873FE                  	call silence_init
  3898 00000FD6 E885FE                  	call putrunint
  3899 00000FD9 E860FE                  	call silence_exit
  3900                                  %if _CATCHINT19
  3901 00000FDC 81FA[0000]              	cmp dx, int19msg
  3902 00000FE0 7409                    	je .noregs		; if it terminated, skip the registers
  3903                                  %endif
  3904 00000FE2 81FA[0000]              	cmp dx, progtrm
  3905 00000FE6 7403                    	je .noregs		; if it terminated, skip the registers
  3906 00000FE8 E8EF03                  	call dumpregs_extended_silent
  3907                                  .noregs:
  3908 00000FEB E8A103                  	call terminate_silent_dump.if_nonnull
  3909 00000FEE E8(0000)                	call silence_dump
  3910                                  
  3911 00000FF1 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  3912 00000FF6 7407                    	jz @F
  3913 00000FF8 F606[0200]20            	testopt [options], gg_unexpected_no_repeat
  3914 00000FFD EB05                    	jmp @FF
  3915                                  @@:
  3916 00000FFF F606[0200]40            	testopt [options], tp_unexpected_no_repeat
  3917                                  @@:
  3918 00001004 7406                    	jz @F
  3919 00001006 C706[0000][0000]        	mov word [lastcmd], dmycmd
  3920                                  @@:
  3921                                  
  3922 0000100C E9(0000)                	jmp cmd3		; back to the start
  3923                                  
  3924                                  
  3925                                  		; Trace an instruction.
  3926                                  		; INP:	word [reg_cs], dword [reg_eip], other register values
  3927                                  		; OUT:	NC if the breakpoint or trace interrupt was hit,
  3928                                  		;	 ah = 0
  3929                                  		;	 ch = 0
  3930                                  		;	 d[reg_eip] adjusted if a breakpoint (bb) hit
  3931                                  		;	 cx & 8 set if trace interrupt hit
  3932                                  		;		(assumed to be the expected trace hit)
  3933                                  		;	 (ZF only set if _BREAKPOINTS)
  3934                                  		;	 ZR if trace interrupt was hit,
  3935                                  		;	  cx & 7 = 0
  3936                                  		;	 NZ if a breakpoint (bb) was hit (or both were hit),
  3937                                  		;	  cx & 1 set if non-pass match (actual hit),
  3938                                  		;	   else cx & 2 set if pass match (consider as hit first,
  3939                                  		;		but dump registers next (not to silent buffer)
  3940                                  		;		and then continue execution)
  3941                                  		;	   else cx & 4 always set, indicates any match
  3942                                  		;		(including matches that should merely continue)
  3943                                  		;	  all pass points' counters stepped
  3944                                  		;	CY if no breakpoint and no trace interrupt was hit,
  3945                                  		;	 cx = 0
  3946                                  		;	If [internalflags2] & dif2_gg_is_gg is set:
  3947                                  		;	 ah & 7Fh = status =	0 = no error,
  3948                                  		;				1 = couldn't write,
  3949                                  		;				2 = unreachable,
  3950                                  		;				3 = overwritten, al = new value
  3951                                  		;	 ah & 80h = set if error restoring point,
  3952                                  		;			else error writing point to begin with
  3953                                  		;	If that flag is clear:
  3954                                  		;	Does not return if a breakpoint cannot be written
  3955                                  		;	 or cannot be restored, jumps to cmd3 instead.
  3956                                  		; CHG:	all
  3957                                  		; STT:	ds = es = ss
  3958                                  		;	might return modeswitched (if dif2_gg_is_gg)
  3959                                  		;	might be called while modeswitched
  3960                                  traceone: section_of_function
  3961 0000100F F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  3962 00001014 7403E9A400              	jnz .proceedbreakpoint
  3963                                  
  3964                                  %if _PM
  3965 00001019 E8F8F9                  	call resetmode
  3966                                  %endif
  3967 0000101C 31C9                    	xor cx, cx
  3968 0000101E E8(0000)                	call getcseipbyte
  3969 00001021 3CCD                    	cmp al, 0CDh		; int opcode?
  3970 00001023 7403E99800              	jne .isstdtrace		; no -->
  3971 00001028 41                      	inc cx
  3972 00001029 E8(0000)                	call getcseipbyte
  3973 0000102C 3C03                    	cmp al, 3
  3974 0000102E 7503E98D00              	je .isstdtrace		; int 3 opcode -->
  3975 00001033 F606[0000]02            	testopt [options], traceints	; TM=1?
  3976 00001038 7503E9F200              	jz isstdtraceX
  3977                                  %if _IMMASM
  3978 0000103D F606[0300]02            	testopt [internalflags6], dif6_immasm
  3979 00001042 7403E9E800              	jnz isstdtraceX
  3980                                  %endif
  3981 00001047 3C01                    	cmp al, 1
  3982 00001049 7475                    	je .isstdtrace		; int 1 opcode -->
  3983                                  
  3984                                  		; TM==1, single-step into the INT
  3985 0000104B 88C3                    	mov bl, al
  3986                                  %if _PM
  3987 0000104D E8(0000)                	call ispm
  3988 00001050 745C                    	jz .singlestep_into_interrupt_pm
  3989                                  %endif
  3990 00001052 B700                    	mov bh, 0
  3991 00001054 1E                      	push ds
  3992 00001055 31C0                    	xor ax, ax
  3993 00001057 8ED8                    	mov ds, ax
  3994 00001059 D1E3                    	shl bx, 1
  3995 0000105B D1E3                    	shl bx, 1
  3996 0000105D C537                    	lds si, [bx]
  3997 0000105F FA                      	cli
  3998 00001060 8A04                    	mov al, byte [si]
  3999 00001062 FE04                    	inc byte [si]
  4000 00001064 3804                    	cmp byte [si], al
  4001 00001066 8804                    	mov byte [si], al
  4002 00001068 FB                      	sti
  4003 00001069 8CDB                    	mov bx, ds		; bx:si-> interrupt handler (RM, 16 bit)
  4004 0000106B 89D8                    	mov ax, bx
  4005 0000106D 1F                      	pop ds
  4006 0000106E 754D                    	jne .singlestep_into_interrupt_setbp
  4007                                  
  4008                                  		; The interrupt handler is in a ROM.
  4009                                  %if 0
  4010                                  	jmp short isstdtraceX
  4011                                  %else
  4012 00001070 8736[0000]              	xchg si, word [reg_eip]
  4013 00001074 8706[0000]              	xchg ax, word [reg_cs]	; get cs:ip, set interrupt handler address
  4014 00001078 8B0E[0000]              	mov cx, word [reg_efl]	; get flags
  4015 0000107C 1E                      	push ds
  4016 0000107D 8B1E[0000]              	mov bx, word [reg_esp]
  4017 00001081 8E1E[0000]              	mov ds, word [reg_ss]	; ds:bx-> debuggee stack
  4018 00001085 83EB06                  	sub bx, byte 6		; reserve enough space for flags, cs, ip
  4019 00001088 46                      	inc si
  4020 00001089 46                      	inc si			; skip CDh xxh opcode
  4021 0000108A 894F04                  	mov word [bx+4], cx
  4022 0000108D 894702                  	mov word [bx+2], ax
  4023 00001090 8937                    	mov word [bx+0], si	; save flags, cs, ip on stack
  4024 00001092 1F                      	pop ds
  4025 00001093 891E[0000]              	mov word [reg_esp], bx	; update sp
  4026 00001097 8026[0100]FC            	and byte [reg_efl+1], ~(2|1)	; clear IF and TF (NC)
  4027                                  			; Note: If invalid flag values were previously set by the user
  4028                                  			; by directly accessing the FL or EFL register, these won't be
  4029                                  			; fixed by us now. This could be worked around by executing a
  4030                                  			; NOP in debuggee's environment (or only with debuggee's flags)
  4031                                  			; first, but I don't think it's much of an issue.
  4032 0000109C C706[0000][0000]        	mov word [run_int], int1msg
  4033 000010A2 8126[0000]7FF8          	clropt [internalflags2], 		dif2_tpg_have_bp | dif2_tpg_adjusted_cseip 		| dif2_tpg_do_not_adjust | dif2_tpg_keep_proceed_bp, 1
  4036 000010A8 B90800                  	mov cx, 8
  4037 000010AB 31C0                    	xor ax, ax		; NC, ZR
  4038 000010AD C3                      	retn
  4039                                  
  4040                                  %endif
  4041                                  %if _PM
  4042                                  .singlestep_into_interrupt_pm:
  4043 000010AE B80402                  	mov ax, 0204h
  4044 000010B1 CD31                    	int 31h
  4045 000010B3 89CB                    	mov bx, cx
  4046 000010B5 66                      	_386_o32	; mov esi, edx
  4047 000010B6 89D6                    	mov si, dx		; bx:(e)si-> interrupt handler
  4048 000010B8 F6C304                  	test bl, 4		; is it a LDT selector? (NC)
  4049 000010BB 7472                    	jz isstdtraceX		; no -->
  4050                                  %endif
  4051                                  .singlestep_into_interrupt_setbp:
  4052                                  .proceedbreakpoint:
  4053 000010BD E9FE04                  	jmp proceedbreakpoint
  4054                                  
  4055                                  .isstdtrace:
  4056                                  %if _PM
  4057 000010C0 E8(0000)                	call ispm
  4058 000010C3 7415                    	jz .notdpmientry	; already in PM -->
  4059 000010C5 A1[0000]                	mov ax, w[reg_eip]	; is this a switch to protected mode ?
  4060 000010C8 3B06[0000]              	cmp ax, w[dpmiwatch+0]
  4061 000010CC 750C                    	jne .notdpmientry
  4062 000010CE A1[0000]                	mov ax, w[reg_cs]
  4063 000010D1 3B06[0200]              	cmp ax, w[dpmiwatch+2]
  4064 000010D5 7503E9C404              	je isdpmientry		; yes, catch it --> (this means really "go")
  4065                                  .notdpmientry:
  4066                                  %endif
  4067 000010DA 800E[0100]01            	or byte [reg_efl+1], 1	; set single-step mode (cleared when returning into DEBUG)
  4068 000010DF 31C9                    	xor cx, cx
  4069 000010E1 E86300                  	call skipprefixes
  4070 000010E4 3C9C                    	cmp al, 9Ch		; opcode "PUSHF"?
  4071 000010E6 7527                    	jnz .notpushf
  4072                                  %if _BREAKPOINTS
  4073 000010E8 E87505                  	call run_with_bb
  4074 000010EB B400                    	mov ah, 0
  4075 000010ED 9C                      	pushf
  4076                                  %else
  4077                                  	call run
  4078                                  	xor cx, cx
  4079                                  	xor ax, ax
  4080                                  %endif
  4081                                  		; Clear TF in the fl word or efl dword
  4082                                  		; pointed to by debuggee's ss:(e)sp
  4083 000010EE 06                      	push es
  4084                                  %if _PM
  4085 000010EF 8B1E[0000]              	mov bx, word [reg_ss]	; get ss selector into bx
  4086 000010F3 8EC3                    	mov es, bx
  4087 000010F5 E8(0000)                _386	call test_d_b_bit	; check whether a 32-bit ss
  4088                                  %else
  4089                                  	mov es, word [reg_ss]
  4090                                  %endif
  4091 000010F8 66                      	_386_PM_o32	; mov ebx, dword [reg_esp]
  4092 000010F9 8B1E[0000]              	mov bx, word [reg_esp]	; es:(e)bx-> debuggee's stack
  4093 000010FD 7408                    _386_PM	jz .pushf_16
  4094 000010FF 2667806301FE            _386_PM	and byte [es:ebx+1], ~1	; clear TF
  4095 00001105 EB05                    _386_PM	jmp short .pushf_common
  4096                                  .pushf_16:
  4097 00001107 26806701FE              	and byte [es:bx+1], ~1	; clear TF
  4098                                  .pushf_common:
  4099 0000110C 07                      	pop es
  4100 0000110D EB06                    	jmp short .checkreturn
  4101                                  .notpushf:
  4102                                  %if _BREAKPOINTS
  4103 0000110F E84E05                  	call run_with_bb
  4104 00001112 B400                    	mov ah, 0
  4105 00001114 9C                      	pushf
  4106                                  %else
  4107                                  	call run
  4108                                  	xor cx, cx
  4109                                  	xor ax, ax
  4110                                  %endif
  4111                                  .checkreturn:
  4112 00001115 813E[0000][0000]        	cmp word [run_int], int1msg
  4113 0000111B 7509                    	jne .nomatch
  4114 0000111D 80C908                  	or cl, 8
  4115                                  %if _BREAKPOINTS
  4116 00001120 9D                      	popf			; CF
  4117 00001121 7308                    	jnc .ret_NZ_NC
  4118                                  %endif
  4119 00001123 38C0                    	cmp al, al		; if correct interrupt (ZR, NC)
  4120 00001125 C3                      	retn
  4121                                  
  4122                                  .nomatch:
  4123                                  %if _BREAKPOINTS
  4124 00001126 9D                      	popf			; CF
  4125 00001127 7302                    	jnc .ret_NZ_NC
  4126                                  %endif
  4127 00001129 F9                      	stc
  4128 0000112A C3                      	retn
  4129                                  
  4130                                  %if _BREAKPOINTS
  4131                                  .ret_NZ_NC:
  4132 0000112B 80C904                  	or cl, 4		; (NZ, NC)
  4133 0000112E C3                      	retn
  4134                                  %endif
  4135                                  
  4136                                  
  4137                                  ; an INT is to be processed (TM is 0)
  4138                                  ; to avoid the nasty x86 bug which makes IRET
  4139                                  ; cause a debug exception 1 instruction too late
  4140                                  ; a breakpoint is set behind the INT
  4141                                  
  4142                                  isstdtraceX:
  4143 0000112F B90200                  	mov cx, 2
  4144 00001132 E84800                  	call iswriteablecseip	; is it ROM ?
  4145 00001135 7289                    	jc traceone.isstdtrace	; is read-only -->
  4146 00001137 8B1E[0000]              	mov bx, word [reg_cs]
  4147                                  
  4148                                  		; (e)si = (e)ip + 2
  4149                                  		; We don't test whether it's a 32-bit code segment here.
  4150                                  		; The previous code would leave the high word of esi uninitialized then.
  4151 0000113B 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
  4152 0000113C 8B36[0000]              	mov si, word [reg_eip]
  4153 00001140 66                      	_386_PM_o32	; add esi, byte 2
  4154 00001141 83C602                  	add si, byte 2		; ! do not remove the byte override, else o32 won't work
  4155 00001144 E97704                  	jmp proceedbreakpoint	; set BP at BX:(E)SI and run debuggee
  4156                                  
  4157                                  		; Call getcseipbyte and loop while increasing cx if the returned
  4158                                  		; byte was a prefix. Returns the first non-prefix byte (an opcode)
  4159                                  		; in al. (WAIT or FWAIT is not considered a prefix because it's
  4160                                  		; really an opcode and we also trace it without executing a
  4161                                  		; following FPU opcode.)
  4162                                  skipprefixes:
  4163                                  .:
  4164 00001147 E8(0000)                	call getcseipbyte
  4165 0000114A 3C26                    	cmp al, 26h
  4166 0000114C 742A                    	je .prefix		; ES
  4167 0000114E 3C2E                    	cmp al, 2Eh
  4168 00001150 7426                    	je .prefix		; CS
  4169 00001152 3C36                    	cmp al, 36h
  4170 00001154 7422                    	je .prefix		; SS
  4171 00001156 3C3E                    	cmp al, 3Eh
  4172 00001158 741E                    	je .prefix		; DS
  4173 0000115A 3CF0                    	cmp al, 0F0h
  4174 0000115C 741A                    	je .prefix		; LOCK
  4175 0000115E 3CF3                    	cmp al, 0F3h
  4176 00001160 7416                    	je .prefix		; REPZ
  4177 00001162 3CF2                    	cmp al, 0F2h
  4178 00001164 7412                    	je .prefix		; REPNZ
  4179 00001166 EB14                    	_no386_jmps .noprefix	; no 386, following aren't prefixes (invalid opcodes on 186+) -->
  4180 00001168 3C64                    	cmp al, 64h
  4181 0000116A 740C                    	je .prefix		; FS
  4182 0000116C 3C65                    	cmp al, 65h
  4183 0000116E 7408                    	je .prefix		; GS
  4184 00001170 3C66                    	cmp al, 66h
  4185 00001172 7404                    	je .prefix		; o32/o16
  4186 00001174 3C67                    	cmp al, 67h
  4187 00001176 7504                    	jne .noprefix		; not a32/a16
  4188                                  .prefix:
  4189 00001178 41                      	inc cx
  4190                                  	; jmp short .
  4191 00001179 79CC                    	jns .			; this is not correct but serves as hack to avoid an infinite loop
  4192                                  				; (note that getcseipbyte really uses cx as signed number)
  4193 0000117B 49                      	dec cx			; back to 07FFFh
  4194                                  .noprefix:
  4195 0000117C C3                      	retn
  4196                                  
  4197                                  
  4198                                  ;--- test if memory at CS:E/IP can be written to
  4199                                  ;--- return C if not
  4200                                  
  4201                                  iswriteablecseip:
  4202 0000117D E8(0000)                	call getcseipbyte	; get byte at CS:EIP+CX
  4203 00001180 88C4                    	mov ah, al
  4204 00001182 34FF                    	xor al, 0FFh
  4205 00001184 E8(0000)                	call setcseipbyte
  4206 00001187 720E                    	jc .return
  4207 00001189 E8(0000)                	call getcseipbyte
  4208 0000118C 38C4                    	cmp ah, al     		; is it ROM?
  4209 0000118E F9                      	stc
  4210 0000118F 7406                    	jz .return
  4211 00001191 88E0                    	mov al, ah
  4212 00001193 E8(0000)                	call setcseipbyte
  4213 00001196 F8                      	clc
  4214                                  .return:
  4215 00001197 C3                      	retn
  4216                                  
  4217                                  
  4218                                  %if _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4219                                  	usesection lDEBUG_DATA_ENTRY
  4219          ------------------       note: usesection lDEBUG_DATA_ENTRY
  4220                                  
  4221                                  r86m_debugger_exception:
  4222 00000002 FA                      	cli
  4223 00000003 8CC8                    	mov ax, cs
  4224 00000005 8ED8                    	mov ds, ax			; => debugger data segment
  4225 00000007 8F06[0000]              	pop word [exception_csip]	; ip
  4226 0000000B 8F06[0200]              	pop word [exception_csip + 2]	; cs
  4227 0000000F 5A                      	pop dx				; get rid of flags
  4228                                   %if _AREAS
  4229 00000010 FC                      	cld
  4230 00000011 8EC0                    	mov es, ax
  4231 00000013 89E6                    	mov si, sp
  4232 00000015 BF[0000]                	mov di, exception_stack
  4233 00000018 B90800                  	mov cx, 8
  4234 0000001B F3A4                    	rep movsb
  4235                                   %endif
  4236 0000001D 8ED0                    	mov ss, ax
  4237                                  %ifn _ONLY386
  4238                                  ..@patch_no386_ds_6_DATA_ENTRY:
  4239 0000001F 66                      	o32			; mov esp, dword [savesp]
  4240                                  %endif
  4241 00000020 8B26[0000]              	mov sp, word [savesp]
  4242 00000024 90                      	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  4243 00000025 E8(0000)                	call entry_to_code_seg
  4244 00000028 [9811]                  	dw .code
  4245                                  
  4246                                  	usesection lDEBUG_CODE
  4246          ------------------       note: usesection lDEBUG_CODE
  4247                                  .code:
  4248 00001198 FB                      	sti
  4249                                  %endif
  4250                                  %if _PM || _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4251                                  debuggerexception:
  4252 00001199 FC                      	cld
  4253 0000119A 16                      	push ss
  4254 0000119B 1F                      	pop ds
  4255                                  %if _DEBUG && _DEBUG_COND
  4256                                  	testopt [options6], opt6_debug_exception
  4257                                  	jz @F
  4258                                  	testopt [internalflags6], dif6_debug_mode
  4259                                  	jnz @F
  4260                                  	call reset_interrupts
  4261                                  	setopt [internalflags6], dif6_debug_mode
  4262                                  	setopt [options6], opt6_debug_mode
  4263                                  @@:
  4264                                  %endif
  4265                                  
  4266                                  %if _DEBUG
  4267                                   %if _DEBUG_COND
  4268                                  	testopt [internalflags6], dif6_debug_mode
  4269                                  	jz @F
  4270                                   %endif
  4271                                  	testopt [options6], opt6_debug_exception_early
  4272                                  	jz @F
  4273                                  	int3
  4274                                  	nop
  4275                                  @@:
  4276                                  %endif
  4277 0000119C E8(0000)                	call unhack		; sets es to ss
  4278                                  
  4279                                  %if _AREAS
  4280 0000119F 8CCB                    	mov bx, cs
  4281 000011A1 3B1E[0200]              	cmp bx, word [exception_csip + 2]
  4282 000011A5 7532                    	jne .unknownarea
  4283 000011A7 A1[0000]                	mov ax, word [exception_csip]
  4284 000011AA BF[A800]                	mov di, areafunctions
  4285 000011AD B90A00                  	mov cx, areafunctions.amount
  4286 000011B0 F2AF                    	repne scasw
  4287 000011B2 7508                    	jne .unknownfunction
  4288 000011B4 BB[0000]                	mov bx, exception_stack
  4289 000011B7 035D12                  	add bx, word [di - areafunctions - 2 + areafunctions.skip]
  4290 000011BA 8B07                    	mov ax, [bx]
  4291                                  .gotfunction:
  4292                                  
  4293                                  .unknownfunction:
  4294 000011BC 89C2                    	mov dx, ax		; = ip
  4295 000011BE BE[3000]                	mov si, areas
  4296 000011C1 B90E00                  	mov cx, areas.amount
  4297                                  .looparea:
  4298 000011C4 AD                      	lodsw
  4299 000011C5 39C2                    	cmp dx, ax
  4300 000011C7 AD                      	lodsw
  4301 000011C8 720B                    	jb .nextarea
  4302 000011CA 39C2                    	cmp dx, ax
  4303 000011CC 7307                    	jae .nextarea
  4304 000011CE AD                      	lodsw
  4305 000011CF 92                      	xchg ax, dx
  4306 000011D0 E8(0000)                	call putsz
  4307 000011D3 EB04                    	jmp .donearea
  4308                                  .nextarea:
  4309 000011D5 AD                      	lodsw
  4310 000011D6 AD                      	lodsw
  4311 000011D7 E2EB                    	loop .looparea
  4312                                  
  4313                                  .donearea:
  4314                                  .unknownarea:
  4315                                  %endif
  4316 000011D9 E8D2FD                  	call putrunint.noarea
  4317                                  %if _EXCCSIP
  4318 000011DC BF[0000]                	mov di, exccsip
  4319 000011DF A1[0200]                	mov ax, word [exception_csip + 2]
  4320 000011E2 E8(0000)                	call hexword
  4321 000011E5 47                      	inc di
  4322 000011E6 A1[0000]                	mov ax, word [exception_csip]
  4323 000011E9 E8(0000)                	call hexword
  4324                                  
  4325 000011EC BA[0000]                	mov dx, excloc
  4326 000011EF E8(0000)                	call putsz
  4327                                  %endif
  4328                                  %if _DEBUG
  4329                                   %if _DEBUG_COND
  4330                                  	testopt [internalflags6], dif6_debug_mode
  4331                                  	jz @F
  4332                                   %endif
  4333                                  	testopt [options6], opt6_debug_exception_late
  4334                                  	jz @F
  4335                                  	int3
  4336                                  @@:
  4337                                  %endif
  4338 000011F2 E9(0000)                	jmp cmd3
  4339                                  %endif	; _PM || _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4340                                  
  4341                                  
  4342                                  %if _AREAS
  4343                                  	usesection lDEBUG_DATA_ENTRY
  4343          ------------------       note: usesection lDEBUG_DATA_ENTRY
  4344                                  
  4345                                  %imacro areadefine 1-2.nolist
  4346                                  	dw ..@%1_start
  4347                                  	dw ..@%1_end
  4348                                  %ifempty %2
  4349                                  	dw msg.area_%1
  4350                                  %else
  4351                                  	dw msg.area_%2
  4352                                  %endif
  4353                                  	dw 0
  4354                                  %endmacro
  4355                                  
  4356                                  %define AREAFUNCTIONS ""
  4357                                  %define AREAFUNCTIONSSKIP ""
  4358                                  %imacro areafunctiondefine 2.nolist
  4359                                  %xdefine AREAFUNCTIONS AREAFUNCTIONS,%1
  4360                                  %xdefine AREAFUNCTIONSSKIP AREAFUNCTIONSSKIP,%2
  4361                                  %endmacro
  4362                                  
  4363 0000002A 00<rep 6h>              	align 8, db 0
  4364                                  areas:
  4365                                  .:
  4366                                  		; More specific areas first!
  4367                                  		;  (The first range match wins.)
  4368 00000030 [0000][0000][0000]-     	areadefine ee_interactive_access
  4368 00000036 0000               
  4369                                  %ifn _DUALCODE && _EXPRDUALCODE
  4370                                  	areadefine hh_indirection_memory_access
  4371                                  %else
  4372 00000038 [0000][0000][0000]-     	areadefine hh_code1_indirection_memory_access, hh_indirection_memory_access
  4372 0000003E 0000               
  4373                                  %endif
  4374 00000040 [0000][0000][0000]-     	areadefine rr_variable_read_access
  4374 00000046 0000               
  4375 00000048 [0000][0000][0000]-     	areadefine rr_variable_write_access
  4375 0000004E 0000               
  4376 00000050 [0000][0000][0000]-     	areadefine uu_referenced_memory_access
  4376 00000056 0000               
  4377 00000058 [0000][0000][0000]-     	areadefine uu_simulate_scas
  4377 0000005E 0000               
  4378 00000060 [0000][0000][0000]-     	areadefine uu_simulate_cmps
  4378 00000066 0000               
  4379 00000068 [0000][0000][0000]-     	areadefine aa_access
  4379 0000006E 0000               
  4380 00000070 [0000][0000][0000]-     	areadefine dd_access
  4380 00000076 0000               
  4381 00000078 [0000][0000][0000]-     	areadefine ee_access
  4381 0000007E 0000               
  4382 00000080 [0000][0000][0000]-     	areadefine rr_access
  4382 00000086 0000               
  4383 00000088 [0000][0000][0000]-     	areadefine sss_access
  4383 0000008E 0000               
  4384 00000090 [0000][B21B][0000]-     	areadefine run_access
  4384 00000096 0000               
  4385 00000098 [0000][0000][0000]-     	areadefine uu_access
  4385 0000009E 0000               
  4386                                  .end:
  4387                                  .amount: equ (.end - .) / 8
  4388                                  
  4389                                  %if _DUALCODE && _EXPRDUALCODE
  4390                                  areas2:
  4391                                  .:
  4392 000000A0 [0000][0000][0000]-     	areadefine hh_indirection_memory_access
  4392 000000A6 0000               
  4393                                  .end:
  4394                                  .amount: equ (.end - .) / 8
  4395                                  %endif
  4396                                  
  4397                                  	areafunctiondefine ..@readmem_fault_skip_4_near_call, 4
  4398                                  	areafunctiondefine ..@writemem_fault_skip_4_near_call_a, 4
  4399                                  	areafunctiondefine ..@writemem_fault_skip_4_near_call_b, 4
  4400                                  	areafunctiondefine ..@getcseipbyte_fault_skip_2_near_call, 2
  4401                                  	areafunctiondefine ..@setcseipbyte_fault_skip_2_near_call, 2
  4402                                  %if _PM
  4403                                  	areafunctiondefine ..@readmem_fault_skip_2_near_call, 2
  4404                                  	areafunctiondefine ..@writemem_fault_skip_2_near_call_a, 2
  4405                                  	areafunctiondefine ..@writemem_fault_skip_2_near_call_b, 2
  4406                                  	areafunctiondefine ..@getcseipbyte_fault_skip_6_near_call, 6
  4407                                  	areafunctiondefine ..@setcseipbyte_fault_skip_6_near_call, 6
  4408                                  %endif
  4409                                  
  4410                                  
  4411                                  	align 2, db 0
  4412                                  areafunctions:
  4413                                  .:
  4414 000000A8 [0000][0000][0000]-     	repeatdw AREAFUNCTIONS
  4414 000000AE [0000][0000][0000]-
  4414 000000B4 [0000][0000][0000]-
  4414 000000BA [0000]             
  4415                                  .end:
  4416                                  .amount: equ (.end - .) / 2
  4417                                  .skip:
  4418 000000BC 040004000400020002-     	repeatdw AREAFUNCTIONSSKIP
  4418 000000C5 000200020002000600-
  4418 000000CE 0600               
  4419                                  
  4420                                  
  4421                                  %if _AREAS_HOOK_CLIENT
  4422                                  areas_struc:
  4423                                  	istruc AREASTRUC
  4424                                  at areastrucEntry
  4425                                  	stc
  4426                                  	retf
  4427                                  at areastrucNext,	dd -1
  4428                                  at areastrucPrev,	dd -1
  4429                                  at areastrucSubAmount,	dw areas_sub_amount
  4430                                  at areastrucSubOffset,	dw areas_sub
  4431                                  at areastrucFunAmount,	dw 1
  4432                                  at areastrucFunOffset,	dw areas_fun
  4433                                  	iend
  4434                                  
  4435                                  areas_sub:
  4436                                  	istruc AREASTRUCSUB
  4437                                  at areastrucsubLinear,		dd 0
  4438                                  at areastrucsubLinearEnd
  4439                                   %ifn _LINK
  4440                                  				dd ldebug_code_size
  4441                                   %else
  4442                                  				dw behind_code wrt lDEBUG_CODE
  4443                                   %endif
  4444                                  at areastrucsubListOffset,	dw areas
  4445                                  at areastrucsubListAmount,	dw areas.amount
  4446                                  	iend
  4447                                  %if _DUALCODE && _EXPRDUALCODE
  4448                                  	istruc AREASTRUCSUB
  4449                                  at areastrucsubLinear,		dd 0
  4450                                  at areastrucsubLinearEnd
  4451                                   %ifn _LINK
  4452                                  				dd ldebug_code2_size
  4453                                   %else
  4454                                  				dw behind_code2 wrt lDEBUG_CODE2
  4455                                   %endif
  4456                                  at areastrucsubListOffset,	dw areas2
  4457                                  at areastrucsubListAmount,	dw areas2.amount
  4458                                  	iend
  4459                                  %endif
  4460                                  areas_sub_amount equ ($ - areas_sub) / AREASTRUCSUB_size
  4461                                  
  4462                                  areas_fun:
  4463                                  	istruc AREASTRUCFUN
  4464                                  at areastrucfunLinear,		dd 0
  4465                                  at areastrucfunLinearEnd
  4466                                   %ifn _LINK
  4467                                  				dd ldebug_code_size
  4468                                   %else
  4469                                  				dw behind_code wrt lDEBUG_CODE
  4470                                   %endif
  4471                                  at areastrucfunListOffset,	dw areafunctions
  4472                                  at areastrucfunListAmount,	dw areafunctions.amount
  4473                                  	iend
  4474                                  %endif
  4475                                  
  4476                                  	usesection lDEBUG_CODE
  4476          ------------------       note: usesection lDEBUG_CODE
  4477                                  %endif
  4478                                  
  4479                                  
  4480                                  %if _PM
  4481                                  [cpu 386]
  4482                                  		; INP:	dh = flags as for pp2,pp3,pp5 (1 = ASIZE, 2 = OSIZE)
  4483                                  		; OUT:	dh = flags as used by pp3,pp5 (1 = A32, 2 = O32)
  4484                                  pp_fix32bitflags: section_of_function
  4485 000011F5 E8(0000)                	call test_d_b_bit
  4486 000011F8 7403                    	jz .16
  4487 000011FA 80F603                  	xor dh, 1|2		; toggle OSIZE and ASIZE (once)
  4488                                  .16:
  4489 000011FD C3                      	retn
  4490                                  __CPU__
  4491                                  %endif
  4492                                  
  4493                                  		; P command - proceed (i.e., skip over call/int/loop/string instruction).
  4494                                  pp:
  4495                                  %if _RH
  4496 000011FE E8(0000)                	call enable_rh
  4497                                  %endif
  4498 00001201 C706[0000][FE11]        	mov word [lastcmd], pp
  4499 00001207 800E[0100]10            	setopt [internalflags2], dif2_is_pp
  4500 0000120C E8C207                  	call parse_pt		; process arguments
  4501                                  
  4502                                  		; Do it <BX:CX=count> times.  First check the type of instruction.
  4503                                  pp1:
  4504 0000120F 53                      	push bx
  4505 00001210 51                      	push cx			; save bx:cx
  4506                                  %if _PM
  4507 00001211 E800F8                  	call resetmode
  4508                                  %endif
  4509 00001214 BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
  4510 00001217 8B1E[0000]              	mov bx, word [reg_cs]
  4511 0000121B 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
  4512 0000121C 8B36[0000]              	mov si, word [reg_eip]
  4513                                  pp2:
  4514 00001220 E83104                  	call pp16		; get next instruction byte into AL
  4515 00001223 BF[0000]                	mov di, ppbytes
  4516 00001226 B9[0000]                	mov cx, PPLEN
  4517 00001229 A2[0000]                	mov byte [pp_instruction], al
  4518 0000122C F2AE                    	repne scasb
  4519 0000122E 7534                    	jne pp5			; if not one of these -->
  4520                                  %if _LINK_COMPAT
  4521 00001230 8A85[FFFF]              	mov al,byte [word di+PPLEN-1]; get corresponding byte in ppinfo
  4522                                  %else
  4523                                  	mov al,byte [di+PPLEN-1]; get corresponding byte in ppinfo
  4524                                  %endif
  4525 00001234 A880                    	test al, PP_PREFIX	; prefix ?
  4526 00001236 740F                    	jz pp3			; no -->
  4527 00001238 08C6                    	or dh, al		; set the OSIZE or ASIZE flags if either of these
  4528                                  			; Note:	Multiple OSIZE in a 16-bit cs do not toggle
  4529                                  			;	between decoding as O32 and O16, they're always
  4530                                  			;	decoded as O32. The same is true for A32, and
  4531                                  			;	in a 32-bit cs for O16 and A16.
  4532 0000123A FECA                    	dec dl
  4533 0000123C 75E2                    	jnz pp2			; if not out of bytes -->
  4534 0000123E BA[0000]                	mov dx, msg.warnprefix
  4535 00001241 E8(0000)                	call putsz
  4536 00001244 E9EE00                  	jmp pp12
  4537                                  
  4538                                  		; A repeatable string, interrupt, call immediate or loop
  4539                                  		; instruction is to be decoded. Finish the decoding and
  4540                                  		; skip the appropriate number of opcode bytes.
  4541                                  pp3:
  4542 00001247 E8ABFF                  _386_PM	call pp_fix32bitflags
  4543 0000124A 66                      	_386_PM_o32
  4544 0000124B 8936[0000]              	mov word [pp_operand], si
  4545 0000124F A840                    	test al, PP_VARSIZ	; different opcode length depends on OSIZE ?
  4546 00001251 7405                    	jz .ignoreosize		; no -->
  4547 00001253 80E602                  	and dh, 2
  4548 00001256 00F0                    	add al, dh
  4549                                  .ignoreosize:
  4550 00001258 83E007                  	and ax, PP_SIZ_MASK
  4551 0000125B 660FB7C0                _386_PM	movzx eax, ax		; clear high word (in case it counts)
  4552 0000125F 66                      	_386_PM_o32	; add esi, eax
  4553 00001260 01C6                    	add si, ax
  4554 00001262 EB5C                    	jmp pp10
  4555                                  
  4556                                  
  4557                                  pp5:
  4558 00001264 E88EFF                  _386_PM	call pp_fix32bitflags
  4559 00001267 3CFF                    	cmp al, 0FFh		; FF/2 or FF/3 indirect NEAR or FAR call ?
  4560 00001269 7403E9C700              	jne pp12		; no, just an ordinary instruction -->
  4561 0000126E E8E303                  	call pp16		; get MOD REG R/M byte
  4562 00001271 24F7                    	and al, ~ (1 << 3)	; clear lowest bit of REG field (/3 to /2)
  4563 00001273 3410                    	xor al, 2 << 3		; /3 or /2 to /0
  4564 00001275 A838                    	test al, 7 << 3
  4565 00001277 7403E9B900              	jnz pp12		; if not FF/2 or FF/3 -->
  4566 0000127C 3CC0                    	cmp al, 0C0h		; mod = 3 ?
  4567 0000127E 7340                    	jae .adjust0		; if just a register -->
  4568 00001280 F6C601                  	test dh, 1
  4569 00001283 750E                    	jnz .a32		; if 32-bit addressing -->
  4570 00001285 3C06                    	cmp al, 6		; mod = 0 r/m = 6 would encode bp ?
  4571 00001287 7433                    	je .adjust2		; if just plain disp16 -->
  4572 00001289 3C40                    	cmp al, 40h
  4573 0000128B 7233                    	jb .adjust0		; if indirect register -->
  4574 0000128D 3C80                    	cmp al, 80h
  4575 0000128F 722D                    	jb .adjust1		; if disp8[reg(s)]
  4576 00001291 EB29                    	jmp short .adjust2	; it's disp16[reg(s)]
  4577                                  
  4578                                  		; Handle 32-bit addressing (A32 ModR/M referencing memory)
  4579                                  .a32:
  4580 00001293 3C05                    	cmp al, 5		; mod = 0 and r/m = 5 (would encode ebp) ?
  4581 00001295 7421                    	je .adjust4		; if just plain disp32 -->
  4582 00001297 3404                    	xor al, 4		; 4 to 0 (r/m 4 would encode esp)
  4583 00001299 A807                    	test al, 7		; 0 if r/m would encode esp
  4584 0000129B 7513                    	jnz .a32_nosib		; if no SIB byte -->
  4585 0000129D 86C4                    	xchg al, ah
  4586 0000129F E8B203                  	call pp16
  4587 000012A2 86C4                    	xchg al, ah		; load and skip the SIB byte
  4588                                  		; The SIB byte is only used here to detect the
  4589                                  		;  special case encoding of disp32 with mod=0
  4590                                  		;  and base=5. index=4 is also special but it
  4591                                  		;  does not alter the size of the displacement
  4592                                  		;  that we have to skip.
  4593 000012A4 A8C0                    	test al, 0C0h		; is it mod = 0 ?
  4594 000012A6 7508                    	jnz @F			; no, not a special case -->
  4595 000012A8 80E407                  	and ah, 7
  4596 000012AB 80FC05                  	cmp ah, 5		; is it base = 5 ?
  4597 000012AE 7408                    	je .adjust4		; yes, special case encoding of disp32 -->
  4598                                  @@:
  4599                                  .a32_nosib:
  4600 000012B0 3C40                    	cmp al, 40h
  4601 000012B2 720C                    	jb .adjust0		; if indirect register -->
  4602 000012B4 3C80                    	cmp al, 80h
  4603 000012B6 7206                    	jb .adjust1		; if disp8[reg(s)] -->
  4604                                  				; otherwise, it's disp32[reg(s)]
  4605                                  .adjust4:
  4606 000012B8 66                      	_386_PM_o32	; inc esi
  4607 000012B9 46                      	inc si			; skip an instruction byte
  4608 000012BA 66                      	_386_PM_o32	; inc esi
  4609 000012BB 46                      	inc si			; skip an instruction byte
  4610                                  .adjust2:
  4611 000012BC 66                      	_386_PM_o32	; inc esi
  4612 000012BD 46                      	inc si			; skip an instruction byte
  4613                                  .adjust1:
  4614 000012BE 66                      	_386_PM_o32	; inc esi
  4615 000012BF 46                      	inc si			; skip an instruction byte
  4616                                  .adjust0:
  4617                                  
  4618                                  pp10:
  4619 000012C0 66                      	_386_PM_o32
  4620 000012C1 56                      	push si
  4621                                  
  4622 000012C2 803E[0000]E8            	cmp byte [pp_instruction], 0E8h
  4623 000012C7 7552                    	jne .done
  4624                                  
  4625 000012C9 66                      	_386_PM_o32
  4626 000012CA 8B36[0000]              	mov si, word [pp_operand]
  4627                                  
  4628 000012CE 6631C0                  _386_PM	xor eax, eax
  4629 000012D1 E88003                  	call pp16
  4630 000012D4 86C4                    	xchg al, ah
  4631 000012D6 E87B03                  	call pp16
  4632 000012D9 86C4                    	xchg al, ah
  4633 000012DB EB05                    _386_PM	jmp @F
  4634 000012DD F6C602                  	test dh, 2
  4635 000012E0 7539                    	jnz .notcallrel16
  4636                                  @@:
  4637 000012E2 F6C602                  _386_PM	test dh, 2
  4638 000012E5 7412                    _386_PM	jz @F
  4639                                  
  4640 000012E7 66C1C010                _386_PM	rol eax, 16
  4641 000012EB E86603                  _386_PM	call pp16
  4642 000012EE 86C4                    _386_PM	xchg al, ah
  4643 000012F0 E86103                  _386_PM	call pp16
  4644 000012F3 86C4                    _386_PM	xchg al, ah
  4645 000012F5 66C1C010                _386_PM	rol eax, 16
  4646                                  @@:
  4647 000012F9 66                      	_386_PM_o32
  4648 000012FA 01C6                    	add si, ax
  4649 000012FC B20F                    	mov dl, 15		; number of bytes to go
  4650                                  .loop:
  4651 000012FE E85303                  	call pp16
  4652 00001301 3CCB                    	cmp al, 0CBh		; retf ?
  4653 00001303 7417                    	je .trace
  4654 00001305 3CCA                    	cmp al, 0CAh		; retf imm16 ?
  4655 00001307 7413                    	je .trace
  4656 00001309 3CCF                    	cmp al, 0CFh		; iret ?
  4657 0000130B 740F                    	je .trace
  4658 0000130D BF[0000]                	mov di, ppbytes
  4659 00001310 B9[0000]                	mov cx, PPLEN_ONLY_PREFIXES
  4660 00001313 F2AE                    	repne scasb
  4661 00001315 7504                    	jne .done
  4662                                  				; if one of the prefixes
  4663 00001317 FECA                    	dec dl
  4664 00001319 75E3                    	jnz .loop		; if not out of bytes -->
  4665                                  
  4666                                  				; fall through: do not trace
  4667                                  .notcallrel16:
  4668                                  .done:
  4669 0000131B A8                      	db __TEST_IMM8		; (skip stc, NC)
  4670                                  .trace:
  4671 0000131C F9                      	stc			; trace
  4672 0000131D 66                      	_386_PM_o32
  4673 0000131E 5E                      	pop si
  4674                                  
  4675 0000131F 7214                    	jc pp12			; trace -->
  4676                                  %if _SYMBOLIC
  4677                                  	call pp3_check_symhints
  4678                                  	jc pp12			; trace -->
  4679                                  %endif
  4680                                  	; jmp pp11		; we have a skippable instruction here
  4681                                  pp11:
  4682 00001321 E8(0000)                _386_PM	call test_d_b_bit
  4683 00001324 7504                    _386_PM	jnz .32			; full 32-bit offset valid -->
  4684 00001326 660FB7F6                _386_PM	movzx esi, si		; clear high word here
  4685                                  .32:
  4686                                  @@:
  4687 0000132A E89102                  	call proceedbreakpoint	; run until the breakpoint is hit
  4688 0000132D 725D                    	jc pp15			; unexpected -->
  4689                                  %if _BREAKPOINTS
  4690 0000132F 7515                    	jnz pp12.bb_hit
  4691                                  %endif
  4692 00001331 31D2                    	xor dx, dx		; do not skip WHILE
  4693 00001333 EB2F                    	jmp short pp13
  4694                                  
  4695                                  pp12:
  4696 00001335 F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  4697 0000133A 75EE                    	jnz @B
  4698                                  
  4699 0000133C E8D0FC                  	call traceone
  4700 0000133F 724B                    	jc pp15
  4701                                  	; jc unexpectedinterrupt
  4702                                  
  4703                                  %if _BREAKPOINTS
  4704 00001341 BA0000                  	mov dx, 0		; do not skip WHILE
  4705 00001344 7416                    	jz @F
  4706                                  
  4707                                  .bb_hit:
  4708 00001346 E84FF9                  	call handle_bb_hit_pass_match
  4709 00001349 7204                    	jc .actual_hit
  4710                                  d5	call d5message
  4711                                  d5	asciz "in pp12.bb_hit after non-hit",13,10
  4712 0000134B 7422                    	jz pp13.nodump
  4713 0000134D EB15                    	jmp pp13
  4714                                  
  4715                                  
  4716                                  .actual_hit:
  4717                                  %if _PM
  4718 0000134F E8C2F6                  	call resetmode
  4719                                  %endif
  4720 00001352 E85AF0                  	call put_deferred_message_silent
  4721 00001355 E88200                  	call dumpregs_extended_silent
  4722 00001358 59                      	pop cx
  4723 00001359 5B                      	pop bx			; (discard counter)
  4724 0000135A EB26                    	jmp @FF
  4725                                  
  4726                                  @@:
  4727                                  %endif
  4728                                  
  4729                                  		; We could check here for the correct address too, but that
  4730                                  		; would require disassembling the instruction and correctly so.
  4731                                  		; (Disassembling it incorrectly would only result in spurious
  4732                                  		; "Unexpected single-step interrupt" messages aborting multi-
  4733                                  		; traces though, so it won't be fatal.)
  4734                                  		; Wouldn't really be useful though: Only the "int1" or "int 01h"
  4735                                  		; instructions should cause this, and their operation means we
  4736                                  		; might as well behave as if the breakpoint was expected.
  4737 0000135C 813E[0000][0000]        	cmp word [run_int], int1msg
  4738 00001362 7528                    	jne pp15		; if some other interrupt (unexpected) -->
  4739                                  
  4740                                  pp13:
  4741 00001364 52                      	push dx
  4742                                  %if _PM
  4743 00001365 E8ACF6                  	call resetmode
  4744                                  %endif
  4745                                  		; An expected breakpoint. Dump registers, then loop.
  4746 00001368 E844F0                  	call put_deferred_message_silent
  4747 0000136B E86C00                  	call dumpregs_extended_silent
  4748 0000136E 5A                      	pop dx			; preserve skip WHILE flag
  4749                                  
  4750                                  .nodump:
  4751 0000136F E8D8F8                  	call tt_handle_while
  4752 00001372 59                      	pop cx
  4753 00001373 5B                      	pop bx
  4754                                  
  4755 00001374 83E901                  	sub cx, 1
  4756 00001377 83DB00                  	sbb bx, 0
  4757                                  
  4758 0000137A 85DB                    	test bx, bx
  4759 0000137C 750B                    	jnz pp14
  4760 0000137E 85C9                    	test cx, cx
  4761 00001380 7507                    	jnz pp14		; back for more -->
  4762                                  
  4763                                  @@:
  4764                                  %if _PM
  4765 00001382 E88FF6                  	call resetmode
  4766                                  %endif
  4767 00001385 E8(0000)                	call silence_dump
  4768                                  
  4769 00001388 C3                      	retn
  4770                                  
  4771                                  %if ($ - pp1 - 1) < 128
  4772                                  pp14: equ pp1
  4773                                  %else
  4774 00001389 E983FE                  pp14:	jmp pp1
  4775                                  %endif
  4776                                  
  4777                                  pp15:
  4778 0000138C E941FC                  	jmp unexpectedinterrupt	; print message about unexpected interrupt
  4779                                  				; and quit
  4780                                  
  4781                                  
  4782                                  %if _SYMBOLIC
  4783                                  		; INP:	bx:(e)si -> where to place breakpoint by default
  4784                                  		;	byte [pp_instruction] = E8h if near immediate call,
  4785                                  		;	 bx:(d)word [pp_operand] -> rel16/rel32
  4786                                  		;	word [reg_cs]:(d)word [reg_eip] = next CS:(E)IP
  4787                                  		; OUT:	NC if no symhint detected or only skip symhints,
  4788                                  		;	 bx:(e)si -> where to place breakpoint
  4789                                  		;		(will be modified if skip symhints occurred)
  4790                                  		;	CY if trace symhints detected
  4791                                  pp3_check_symhints:
  4792                                  	nearcall zz_detect_xms		; re-detect XMS if used after run
  4793                                  
  4794                                  		; Check for ..@symhint_trace|skip_caller_* hint at called address.
  4795                                  pp3_check_trace_caller_or_skip_caller:
  4796                                  	xor ax, ax
  4797                                  	lframe
  4798                                  	lenter
  4799                                  	lvar word,	segment
  4800                                  	 push bx
  4801                                  	lvar dword,	offset
  4802                                  %ifn _PM
  4803                                  	 push ax
  4804                                  %else
  4805                                  _no386	 push ax
  4806                                  %endif
  4807                                  	_386_PM_o32
  4808                                  	 push si
  4809                                  	lvar word,	skip
  4810                                  	 push ax
  4811                                  
  4812                                  	mov al, byte [pp_instruction]
  4813                                  	cmp al, 0E8h
  4814                                  	jne .notcallrel16
  4815                                  	_386_PM_o32
  4816                                  	mov si, word [pp_operand]
  4817                                  
  4818                                  _386_PM	movzx eax, ax
  4819                                  	call pp16
  4820                                  	xchg al, ah
  4821                                  	call pp16
  4822                                  	xchg al, ah
  4823                                  _386_PM	jmp @F
  4824                                  	test dh, 2
  4825                                  	jnz .notcallrel16
  4826                                  @@:
  4827                                  _386_PM	test dh, 2
  4828                                  _386_PM	jz @F
  4829                                  
  4830                                  _386_PM	rol eax, 16
  4831                                  _386_PM	call pp16
  4832                                  _386_PM	xchg al, ah
  4833                                  _386_PM	call pp16
  4834                                  _386_PM	xchg al, ah
  4835                                  _386_PM	rol eax, 16
  4836                                  @@:
  4837                                  	_386_PM_o32
  4838                                  	add si, ax
  4839                                  	_386_PM_o32
  4840                                  	mov dx, si
  4841                                  	call getlinear_d_b
  4842                                  	jc @F
  4843                                  	mov cx, dx
  4844                                  	mov bx, ax
  4845                                  	nearcall binsearchmain		; search for matching symbol
  4846                                  	jcxz @F
  4847                                  .loop_symbol:
  4848                                  	 push bx			; main index
  4849                                  	 push ax			; (reserve space, uninitialised)
  4850                                  	dualcall getfarpointer.main
  4851                                  	 pop di
  4852                                  	 pop es
  4853                                  
  4854                                  	test byte [es:di + smFlags + 1], smfSymHint >> 8
  4855                                  	jz .next_symbol
  4856                                  
  4857                                  	nearcall zz_copy_strings_to_str_buffer
  4858                                  
  4859                                  	push cx
  4860                                  	push ss
  4861                                  	pop es
  4862                                  	mov di, str_buffer + msg.symhint_size
  4863                                  	mov si, msg.trace_caller
  4864                                  	mov cx, msg.trace_caller_size
  4865                                  	push di
  4866                                  	repe cmpsb
  4867                                  	pop di
  4868                                  	pop cx
  4869                                  	je pp3_trace
  4870                                  
  4871                                  	push cx
  4872                                  	mov si, msg.skip_caller
  4873                                  	mov cx, msg.skip_caller_size
  4874                                  	repe cmpsb
  4875                                  	pop cx
  4876                                  	jne .next_symbol
  4877                                  
  4878                                  	call pp3_handle_skip_di
  4879                                  
  4880                                  .next_symbol:
  4881                                  	inc bx
  4882                                  	loop .loop_symbol
  4883                                  
  4884                                  @@:
  4885                                  .notcallrel16:
  4886                                  
  4887                                  
  4888                                  		; Check for ..@symhint_trace|skip_here_* hint at cs:eip address.
  4889                                  pp3_check_trace_here_or_skip_here:
  4890                                  	mov bx, word [reg_cs]
  4891                                  	_386_PM_o32
  4892                                  	mov dx, word [reg_eip]
  4893                                  	call getlinear_d_b
  4894                                  	jc @F
  4895                                  	mov cx, dx
  4896                                  	mov bx, ax
  4897                                  	nearcall binsearchmain		; search for matching symbol
  4898                                  	jcxz @F
  4899                                  .loop_symbol:
  4900                                  	 push bx			; main index
  4901                                  	 push ax			; (reserve space, uninitialised)
  4902                                  	dualcall getfarpointer.main
  4903                                  	 pop di
  4904                                  	 pop es
  4905                                  
  4906                                  	test byte [es:di + smFlags + 1], smfSymHint >> 8
  4907                                  	jz .next_symbol
  4908                                  
  4909                                  	nearcall zz_copy_strings_to_str_buffer
  4910                                  
  4911                                  	push cx
  4912                                  	push ss
  4913                                  	pop es
  4914                                  	mov di, str_buffer + msg.symhint_size
  4915                                  	mov si, msg.trace_here
  4916                                  	mov cx, msg.trace_here_size
  4917                                  	push di
  4918                                  	repe cmpsb
  4919                                  	pop di
  4920                                  	pop cx
  4921                                  	je pp3_trace
  4922                                  
  4923                                  	push cx
  4924                                  	mov si, msg.skip_here
  4925                                  	mov cx, msg.skip_here_size
  4926                                  	repe cmpsb
  4927                                  	pop cx
  4928                                  	jne .next_symbol
  4929                                  
  4930                                  	call pp3_handle_skip_di
  4931                                  
  4932                                  .next_symbol:
  4933                                  	inc bx
  4934                                  	loop .loop_symbol
  4935                                  
  4936                                  @@:
  4937                                  	db __TEST_IMM8		; skip stc, NC
  4938                                  pp3_trace:
  4939                                  	stc
  4940                                  
  4941                                  	push ss
  4942                                  	pop es
  4943                                  	push ss
  4944                                  	pop ds
  4945                                  
  4946                                  	mov word [stack_low_address], str_buffer
  4947                                  
  4948                                  	pop dx			; ?skip
  4949                                  	_386_PM_o32
  4950                                  	pop si			; ?offset
  4951                                  %ifn _PM
  4952                                  	pop ax			; ?offset high word
  4953                                  %else
  4954                                  _no386	pop ax			; ?offset high word (if it was not pop esi)
  4955                                  %endif
  4956                                  	pop bx			; ?segment
  4957                                  				; restore bx:(e)si if proceeding, else discard
  4958                                  	lleave code
  4959                                  	lahf
  4960                                  _386_PM	movzx edx, dx
  4961                                  	_386_PM_o32
  4962                                  	add si, dx
  4963                                  	sahf
  4964                                  	retn
  4965                                  
  4966                                  
  4967                                  		; INP:	ds:di -> symbol with ASCIZ keyword or expression
  4968                                  		;	word [bp + ?segment] = segment/selector of breakpoint
  4969                                  		;	(d)word [bp + ?offset] = offset of breakpoint
  4970                                  		; OUT:	word [bp + ?skip] = how far to skip
  4971                                  		; CHG:	esi, dx, ax
  4972                                  		; STT:	es = ds = ss
  4973                                  pp3_handle_skip_di:
  4974                                  	push bx
  4975                                  	push cx
  4976                                  
  4977                                  	mov si, di
  4978                                  @@:
  4979                                  	lodsb
  4980                                  	cmp al, 0
  4981                                  	je .expr_have
  4982                                  	cmp al, '_'
  4983                                  	jne @B
  4984                                  	mov byte [si - 1], 0
  4985                                  .expr_have:
  4986                                  	mov si, di
  4987                                  	mov dx, msg.asciz
  4988                                  	call isstring?
  4989                                  	jne .expr_num
  4990                                  	xor cx, cx
  4991                                  	mov bx, word [bp + ?segment]
  4992                                  	_386_PM_o32
  4993                                  	mov si, word [bp + ?offset]
  4994                                  .expr_asciz_loop:
  4995                                  	call pp16
  4996                                  	test al, al
  4997                                  	loopnz .expr_asciz_loop
  4998                                  	jcxz .error
  4999                                  	neg cx
  5000                                  	mov dx, cx
  5001                                  	jmp .expr_got
  5002                                  
  5003                                  .error:
  5004                                  	mov si, line_in + 2
  5005                                  	jmp error
  5006                                  
  5007                                  .expr_num:
  5008                                  	lodsb
  5009                                  	nearcall getword
  5010                                  .expr_got:
  5011                                  	mov word [bp + ?skip], dx
  5012                                  
  5013                                  	pop cx
  5014                                  	pop bx
  5015                                  	retn
  5016                                  
  5017                                  	lleave ctx
  5018                                  
  5019                                  
  5020                                  		; INP:	bx = SYMMAIN index
  5021                                  		; CHG:	es, di, si, dx, ax
  5022                                  		; STT:	ss = ds
  5023                                  		;
  5024                                  		; Note:	This invalidates the access slice.
  5025                                  zz_copy_strings_to_str_buffer: section_of_function
  5026                                  	mov word [stack_low_address], stack
  5027                                  
  5028                                  	push cx
  5029                                  
  5030                                  	 push bx			; main index
  5031                                  	 push ax			; (reserve space, uninitialised)
  5032                                  	dualcall getfarpointer.main
  5033                                  	 pop di
  5034                                  	 pop es
  5035                                  	push ds
  5036                                  		; Here we depend on str_buffer being 512-bytes long,
  5037                                  		;  to allow storing both smName1 and smName2 contents
  5038                                  		;  one after another in str_buffer.
  5039                                  	nearcall getstring1
  5040                                  	 push ss
  5041                                  	 pop es
  5042                                  	mov si, dx
  5043                                  	mov di, str_buffer
  5044                                  	rep movsb
  5045                                  	mov si, di
  5046                                  	pop ds
  5047                                  	 push bx			; main index
  5048                                  	 push ax			; (reserve space, uninitialised)
  5049                                  	dualcall getfarpointer.main
  5050                                  	 pop di
  5051                                  	 pop es
  5052                                  	push ds
  5053                                  	nearcall getstring2
  5054                                  	 push ss
  5055                                  	 pop es
  5056                                  	mov di, si
  5057                                  	mov si, dx
  5058                                  	rep movsb
  5059                                  	mov al, 0
  5060                                  	stosb
  5061                                  	pop ds
  5062                                  
  5063                                  	pop cx
  5064                                  	retn
  5065                                  %endif
  5066                                  
  5067                                  
  5068                                  terminate_silent_dump.if_nonnull:
  5069                                  %if _RH
  5070 0000138F F606[0200]10            	testopt [options6], opt6_rh_mode
  5071 00001394 7507                    	jnz @F
  5072                                  %endif
  5073 00001396 F606[0300]10            	testopt [internalflags], tt_silent_mode
  5074 0000139B 743C                    	jz terminate_silent_dump.ret
  5075                                  @@:
  5076 0000139D 06                      	push es
  5077 0000139E 57                      	push di
  5078 0000139F 50                      	push ax
  5079 000013A0 8E06[0000]              	mov es, word [auxbuff_segorsel]
  5080 000013A4 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  5081                                  %if _PM
  5082 000013A8 3B3E[0000]              	cmp di, word [auxbuff_switchbuffer_size]
  5083 000013AC 7428                    	je terminate_silent_dump.done
  5084                                  %else
  5085                                  	test di, di
  5086                                  	jz terminate_silent_dump.done
  5087                                  %endif
  5088 000013AE 4F                      	dec di
  5089 000013AF B000                    	mov al, 0
  5090 000013B1 AE                      	scasb
  5091 000013B2 7422                    	je terminate_silent_dump.done
  5092 000013B4 EB1B                    	jmp @FF
  5093                                  
  5094                                  terminate_silent_dump:
  5095                                  %if _RH
  5096 000013B6 F606[0200]10            	testopt [options6], opt6_rh_mode
  5097 000013BB 7507                    	jnz @F
  5098                                  %endif
  5099 000013BD F606[0300]10            	testopt [internalflags], tt_silent_mode
  5100 000013C2 7415                    	jz .ret
  5101                                  @@:
  5102                                  .is_silent:
  5103 000013C4 06                      	push es
  5104 000013C5 57                      	push di
  5105 000013C6 50                      	push ax
  5106 000013C7 8E06[0000]              	mov es, word [auxbuff_segorsel]
  5107 000013CB 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  5108 000013CF B000                    	mov al, 0
  5109                                  @@:
  5110 000013D1 AA                      	stosb
  5111 000013D2 FF06[0000]              	inc word [auxbuff_behind_last_silent]
  5112                                  				; -> point past the NUL
  5113                                  .done:
  5114 000013D6 58                      	pop ax
  5115 000013D7 5F                      	pop di
  5116 000013D8 07                      	pop es
  5117                                  .ret:
  5118 000013D9 C3                      	retn
  5119                                  
  5120                                  
  5121                                  dumpregs_extended_silent:
  5122                                  %if _PM
  5123 000013DA E837F6                  	call resetmode
  5124                                  %endif
  5125 000013DD E869FA                  	call silence_init
  5126                                  		; Call dumpregs (trimputs, puts, putsline, disasm) with
  5127                                  		;  "silence" flag (writes to auxbuff instead of terminal).
  5128 000013E0 E8(0000)                	call dumpregs_extended
  5129                                  
  5130                                  %ifn _RH
  5131                                  		; Terminate the last dump's output with a NUL byte.
  5132                                  	call terminate_silent_dump.if_nonnull
  5133                                  %endif
  5134 000013E3 E856FA                  	call silence_exit
  5135                                  %endif	; !_LOADER
  5136                                  
  5137                                  
  5138                                  handle_serial_flags_ctrl_c: section_of_function
  5139 000013E6 1E                      	push ds
  5140 000013E7 50                      	push ax
  5141 000013E8 16                      	 push ss
  5142 000013E9 1F                      	 pop ds
  5143 000013EA F606[0300]40            	testopt [options3], opt3_check_ctrlc_0bh
  5144 000013EF 740A                    	jz @FF
  5145                                  		; The following DOS call originated in sleepcmd.
  5146                                  		;  However, it is useful for all callers of this
  5147                                  		;  function so put it here.
  5148 000013F1 E8(0000)                	call InDOS
  5149 000013F4 7505                    	jnz @F
  5150 000013F6 B40B                    	mov ah, 0Bh
  5151                                  	doscall			; allow to break with Ctrl-C
  1491 000013F8 E8(0000)            <1>  nearcall _doscall
  5152                                  @@:
  5153                                  @@:
  5154 000013FB F606[0000]02            	testopt [serial_flags], sf_ctrl_c
  5155 00001400 755B                    	jnz handle_ctrl_c
  5156 00001402 F606[0000]10            	testopt [serial_flags], sf_use_serial
  5157 00001407 7551                    	jnz .ret
  5158 00001409 E8(0000)                	call InDOS_or_BIOS_IO
  5159 0000140C 744C                    	jz .ret
  5160 0000140E F606[0300]20            	testopt [options3], opt3_check_ctrlc_keyb
  5161 00001413 7445                    	jz .ret
  5162                                  
  5163                                  .check_rombios_buffer:
  5164 00001415 53                      	push bx
  5165 00001416 52                      	push dx
  5166 00001417 B84000                  	mov ax, 40h		; dual mode segment/selector
  5167 0000141A 50                      	 push ax
  5168 0000141B A1[0000]                	mov ax, word [io_end_buffer]
  5169 0000141E 8B16[0000]              	mov dx, word [io_start_buffer]
  5170 00001422 1F                      	 pop ds
  5171 00001423 85C0                    	test ax, ax
  5172 00001425 7503                    	jnz @F
  5173 00001427 A18200                  	mov ax, word [82h]	; end of circular keypress buffer
  5174                                  @@:
  5175 0000142A 85D2                    	test dx, dx
  5176 0000142C 7504                    	jnz @F
  5177 0000142E 8B168000                	mov dx, word [80h]	; start of circular buffer
  5178                                  @@:
  5179 00001432 89C3                    	mov bx, ax
  5180 00001434 29D3                    	sub bx, dx		; cmp end, start
  5181 00001436 7620                    	jbe .ret_dx_bx		; invalid -->
  5182 00001438 F6C301                  	test bl, 1		; even amount of bytes ?
  5183 0000143B 751B                    	jnz .ret_dx_bx		; invalid -->
  5184 0000143D 8B1E1A00                	mov bx, word [1Ah]	; current head of circular buffer
  5185                                  .loop:
  5186 00001441 3B1E1C00                	cmp bx, word [1Ch]	; equal to current tail ?
  5187 00001445 7411                    	je .ret_dx_bx		; yes, all entries checked -->
  5188 00001447 803F03                  	cmp byte [bx], 3	; is it Ctrl-C ?
  5189 0000144A 7411                    	je handle_ctrl_c	; yes, handle -->
  5190 0000144C 43                      	inc bx
  5191 0000144D 43                      	inc bx			; -> next entry
  5192 0000144E 39C3                    	cmp bx, ax		; at end of buffer ?
  5193 00001450 72EF                    	jb .loop		; no, loop -->
  5194 00001452 7704                    	ja .ret_dx_bx		; invalid -->
  5195 00001454 89D3                    	mov bx, dx		; reset to start of buffer
  5196 00001456 EBE9                    	jmp .loop		; then loop -->
  5197                                  
  5198                                  .ret_dx_bx:
  5199 00001458 5A                      	pop dx
  5200 00001459 5B                      	pop bx
  5201                                  
  5202                                  .ret:
  5203 0000145A 58                      	pop ax
  5204 0000145B 1F                      	pop ds
  5205 0000145C C3                      	retn
  5206                                  
  5207                                  
  5208                                  handle_ctrl_c:
  5209 0000145D 16                      	 push ss
  5210 0000145E 1F                      	 pop ds
  5211 0000145F 16                      	 push ss
  5212 00001460 07                      	 pop es
  5213                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  5214 00001461 C606[0000]00            	mov byte [in_getinput], 0
  5215                                  %endif
  5216 00001466 8026[0000]F9            	clropt [serial_flags], sf_ctrl_c | sf_double_ctrl_c
  5217                                  %if _PM
  5218 0000146B E8A6F5                  	call resetmode
  5219                                  %endif
  5220                                  %if !_LOADER
  5221 0000146E E81EFF                  	call terminate_silent_dump.if_nonnull
  5222 00001471 E8(0000)                	call silence_dump
  5223                                  %endif
  5224 00001474 BA[0000]                	mov dx, msg.ctrlc
  5225 00001477 E8(0000)                	call putsz
  5226                                  
  5227 0000147A 800E[0000]10            	setopt [internalflags3], dif3_input_terminal_override
  5228                                  				; make sure we drain terminal input
  5229                                  @@:
  5230 0000147F E8(0000)                	call getc_if_any	; drain the buffer
  5231 00001482 75FB                    	jnz @B			; if any was available -->
  5232                                  
  5233 00001484 8026[0000]EF            	clropt [internalflags3], dif3_input_terminal_override
  5234 00001489 E9(0000)                	jmp cmd2_reset_re
  5235                                  
  5236                                  
  5237                                  %if !_LOADER
  5238                                  		; INP:	bp [tpg_proceed_bp],
  5239                                  		;	 linear address and point content to write
  5240                                  		;	opt [internalflags2] & dif2_tpg_proceed_bp_set
  5241                                  		;	 set if a breakpoint was written
  5242                                  		; OUT:	CY if error,
  5243                                  		;	 bp [tpg_proceed_bp] = has point content to restore
  5244                                  		;	 ah = reason =	0 = no error (never),
  5245                                  		;			1 = couldn't write,
  5246                                  		;			2 = unreachable,
  5247                                  		;			3 = overwritten, al = new byte value
  5248                                  		;	NC if no error,
  5249                                  		;	 ah = 0
  5250                                  		;	 opt [internalflags2] & dif2_tpg_proceed_bp_set
  5251                                  		;	  cleared
  5252                                  		; CHG:	di, (e)dx, ax, bx
  5253                                  		; STT:	might switch modes due to getsegmented call
  5254                                  proceed_writepoint_restore:
  5255 0000148C B400                    	mov ah, 0
  5256 0000148E F606[0000]40            	testopt [internalflags2], dif2_tpg_proceed_bp_set
  5257 00001493 745F                    	jz proceed_wp.retn	; (NC)
  5258 00001495 BF0100                  	mov di, 1
  5259 00001498 EB05                    	jmp proceed_wp
  5260                                  
  5261                                  		; INP:	bp [tpg_proceed_bp],
  5262                                  		;	 linear address and point content to write (0CCh)
  5263                                  		; OUT:	CY if error,
  5264                                  		;	 bp [tpg_proceed_bp] = has point content 0CCh
  5265                                  		;	 ah = reason =	0 = no error (never),
  5266                                  		;			1 = couldn't write,
  5267                                  		;			2 = unreachable,
  5268                                  		;			3 = overwritten (never)
  5269                                  		;	NC if no error (either flag not set or point restored),
  5270                                  		;	 ah = 0
  5271                                  		;	 opt [internalflags2] & dif2_tpg_proceed_bp_set
  5272                                  		;	  set
  5273                                  		; CHG:	di, (e)dx, ax, bx
  5274                                  		; STT:	might switch modes due to getsegmented call
  5275                                  proceed_writepoint:
  5276                                  %if _DELAY_BEFORE_BP
  5277 0000149A E848F1                  	call delay_before_bp
  5278                                  %endif
  5279 0000149D 31FF                    	xor di, di
  5280                                  proceed_wp:
  5281                                  	lframe near
  5282 0000149F 5589E5                  	lenter
  5283 000014A2 83F701                  	xor di, 1
  5284                                  	lvar	word, is_write
  5285 000014A5 57                      	 push di
  5286                                  
  5287 000014A6 A1[0000]                	mov ax, word [tpg_proceed_bp]
  5288                                  %if _PM
  5289 000014A9 8B16[0200]              	mov dx, word [tpg_proceed_bp + 2]
  5290                                  %else
  5291                                  	xor dx, dx
  5292                                  	mov dl, byte [tpg_proceed_bp + 2]
  5293                                  %endif
  5294 000014AD E889F5                  	call getsegmented
  5295 000014B0 A0[0800]                	mov al, byte [tpg_proceed_bp + BPSIZE - 1]
  5296                                  				; al = byte to restore
  5297 000014B3 B402                    	mov ah, 2		; error reason: unreachable
  5298 000014B5 723A                    	jc .return
  5299                                  
  5300 000014B7 F646FE01                	test byte [bp + ?is_write], 1
  5301                                  				; (NC) is it writing ?
  5302 000014BB 7518                    	jnz .write
  5303                                  .restore:
  5304 000014BD 50                      	push ax
  5305 000014BE E8(0000)                	call readmem		; read current byte
  5306 000014C1 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  5307 000014C3 B403                    	mov ah, 3		; error reason: overwritten, al = new value
  5308 000014C5 F9                      	stc
  5309 000014C6 7529                    	jne .return_discard	; nope --> (CY)
  5310 000014C8 58                      	pop ax
  5311 000014C9 E8(0000)                	call writemem		; return the byte to its original value
  5312 000014CC 720D                    	jc .next		; failed --> (CY, handled there)
  5313 000014CE C606[0800]CC            	mov byte [tpg_proceed_bp + BPSIZE - 1], 0CCh
  5314                                  				; reset stored point
  5315 000014D3 EB06                    	jmp short .next
  5316                                  
  5317                                  .write:
  5318 000014D5 E8(0000)                	call writemem
  5319 000014D8 A2[0800]                	mov byte [tpg_proceed_bp + BPSIZE - 1], al
  5320                                  				; save the previous byte there
  5321                                  .next:
  5322 000014DB B401                    	mov ah, 1		; (in case of error) error reason: cannot write
  5323 000014DD 7212                    	jc .return		; failed to write --> (CY)
  5324 000014DF B400                    	mov ah, 0		; (no error)
  5325                                  
  5326 000014E1 800E[0000]40                    setopt [internalflags2], dif2_tpg_proceed_bp_set
  5327                                  				; set flag in case of successful writing
  5328 000014E6 F646FE01                	test byte [bp + ?is_write], 1
  5329                                  				; (NC) is it writing ?
  5330 000014EA 7505                    	jnz .return		; yes, leave flag set -->
  5331 000014EC 8026[0000]BF                    clropt [internalflags2], dif2_tpg_proceed_bp_set
  5332                                  				; (NC) clear flag in case of successful restoring
  5333                                  .return:
  5334                                  .return_discard:
  5335 000014F1 89EC5D                  	lleave
  5336                                  .retn:
  5337 000014F4 C3                      	retn
  5338                                  
  5339                                  
  5340                                  		; INP:	ah & 7Fh = status =	0 = no error,
  5341                                  		;				1 = couldn't write,
  5342                                  		;				2 = unreachable,
  5343                                  		;				3 = overwritten, al = new value
  5344                                  		;	ah & 80h = set if error restoring point,
  5345                                  		;			else error writing point
  5346                                  		;	bh & 80h = set if gg breakpoint,
  5347                                  		;	 cx = index (0-based)
  5348                                  		;	bh & 40h = set if bb breakpoint,
  5349                                  		;	 cx = index (0-based)
  5350                                  		;	bh & C0h = clear if proceed breakpoint
  5351                                  		;	bl = what we tried to restore, only set if ah & 80h set
  5352                                  		;	dword [ss:sp] = linear address (24 bit if non-_PM)
  5353                                  		; CHG:	ax, bx, cx, dx, di
  5354                                  		; STT:	ds = es = ss = debugger data selector
  5355                                  display_breakpoint_failure:
  5356                                  %if _PM
  5357 000014F5 E81CF5                  	call resetmode
  5358                                  %endif
  5359                                  
  5360 000014F8 50                      	push ax
  5361 000014F9 53                      	push bx
  5362 000014FA 51                      	push cx
  5363 000014FB 56                      	push si
  5364 000014FC E8(0000)                	call silence_dump	; do away with silent mode
  5365 000014FF 5E                      	pop si
  5366 00001500 59                      	pop cx
  5367 00001501 5B                      	pop bx
  5368 00001502 58                      	pop ax
  5369                                  
  5370 00001503 800E[0100]08            	setopt [internalflags2], dif2_bp_failure
  5371                                  
  5372                                  	lframe near
  5373                                  	lpar dword, linear
  5374 00001508 5589E5                  	lenter
  5375                                  	lvar word, input_ax
  5376 0000150B 50                      	 push ax
  5377                                  
  5378 0000150C BA[0000]                	mov dx, msg.cant_bp_the
  5379 0000150F E8(0000)                	call putsz
  5380 00001512 F6C780                  	test bh, 80h
  5381 00001515 740B                    	jz @F
  5382                                  
  5383 00001517 89C8                    	mov ax, cx
  5384 00001519 40                      	inc ax			; make it 1-based
  5385 0000151A E8F6F2                  	call putordinalbyte
  5386                                  
  5387 0000151D BA[0000]                	mov dx, msg.cant_bp_type_gg
  5388 00001520 EB15                    	jmp .got_type
  5389                                  
  5390                                  @@:
  5391 00001522 F6C740                  	test bh, 40h
  5392 00001525 740D                    	jz @F
  5393                                  
  5394 00001527 89C8                    	mov ax, cx
  5395 00001529 BF[0000]                	mov di, msg.cant_bp_type_permanent.index
  5396 0000152C E8(0000)                	call hexbyte		; (0-based index)
  5397                                  
  5398 0000152F BA[0000]                	mov dx, msg.cant_bp_type_permanent
  5399                                  %if _SYMBOLIC
  5400                                  	sub ax, _NUM_B_BP
  5401                                  	jb .got_type
  5402                                  
  5403                                  	mov di, msg.cant_bp_type_symbol.index
  5404                                  	call hexbyte		; (0-based index)
  5405                                  
  5406                                  	mov dx, msg.cant_bp_type_symbol
  5407                                  %endif
  5408 00001532 EB03                    	jmp .got_type
  5409                                  
  5410                                  @@:
  5411 00001534 BA[0000]                	mov dx, msg.cant_bp_type_proceed
  5412                                  
  5413                                  .got_type:
  5414 00001537 E8(0000)                	call putsz
  5415                                  
  5416 0000153A BF[0000]                	mov di, msg.cant_bp_linear.address1
  5417 0000153D 8B4606                  	mov ax, word [bp + ?linear + 2]
  5418                                  %ifn _PM
  5419                                  	mov ah, 0
  5420                                  %endif
  5421 00001540 E8(0000)                	call hexword
  5422 00001543 47                      	inc di
  5423                                  	; mov di, msg.cant_bp_linear.address2
  5424 00001544 8B4604                  	mov ax, word [bp + ?linear]
  5425 00001547 E8(0000)                	call hexword
  5426                                  
  5427 0000154A BA[0000]                	mov dx, msg.cant_bp_linear
  5428 0000154D E8(0000)                	call putsz
  5429                                  
  5430 00001550 BF[0000]                	mov di, msg.cant_bp_restore.value
  5431 00001553 89D8                    	mov ax, bx
  5432 00001555 E8(0000)                	call hexbyte
  5433                                  
  5434 00001558 BA[0000]                	mov dx, msg.cant_bp_write
  5435 0000155B 8B46FE                  	mov ax, word [bp + ?input_ax]
  5436 0000155E F6C480                  	test ah, 80h
  5437 00001561 7406                    	jz @F
  5438 00001563 80E47F                  	and ah, ~80h
  5439 00001566 BA[0000]                	mov dx, msg.cant_bp_restore
  5440                                  @@:
  5441 00001569 E8(0000)                	call putsz
  5442                                  
  5443 0000156C BF[0000]                	mov di, msg.cant_bp_reason3.value
  5444 0000156F E8(0000)                	call hexbyte
  5445                                  
  5446 00001572 BA[0000]                	mov dx, msg.cant_bp_reason
  5447 00001575 E8(0000)                	call putsz
  5448                                  
  5449 00001578 BA[0000]                	mov dx, msg.cant_bp_reason0
  5450 0000157B 80FC01                  	cmp ah, 1
  5451 0000157E 7215                    	jb @F
  5452 00001580 BA[0000]                	mov dx, msg.cant_bp_reason1
  5453 00001583 7410                    	je @F
  5454 00001585 BA[0000]                	mov dx, msg.cant_bp_reason2
  5455 00001588 80FC03                  	cmp ah, 3
  5456 0000158B 7208                    	jb @F
  5457 0000158D BA[0000]                	mov dx, msg.cant_bp_reason3
  5458 00001590 7403                    	je @F
  5459 00001592 BA[0000]                	mov dx, msg.cant_bp_reasonu
  5460                                  @@:
  5461 00001595 E8(0000)                	call putsz
  5462                                  
  5463 00001598 89EC5D                  	lleave
  5464 0000159B C20400                  	lret
  5465                                  
  5466                                  
  5467                                  %if _PM
  5468                                  isdpmientry:
  5469 0000159E F606[0000]02            	testopt [internalflags4], dif4_int_2F_hooked
  5470 000015A3 750A                    	jnz .stdhook
  5471 000015A5 C706[0000][0000]        	mov word [reg_eip], mydpmientry
  5472 000015AB 8C1E[0000]              	mov word [reg_cs], ds	; if Int2F not hooked, point to the hook here
  5473                                  				; ds => lDEBUG_DATA_ENTRY
  5474                                  .stdhook:
  5475                                  		; Run code until it returned far.
  5476 000015AF 8B1E[0000]              	mov bx, word [reg_esp]
  5477 000015B3 1E                      	push ds
  5478 000015B4 8E1E[0000]              	mov ds, word [reg_ss]	; ds:bx-> (16-bit) stack
  5479 000015B8 8B37                    	mov si, word [bx+0]
  5480 000015BA 8B5F02                  	mov bx, word [bx+2]	; get (16-bit) far return address
  5481 000015BD 1F                      	pop ds
  5482                                  %endif
  5483                                  		; Proceed over an instruction
  5484                                  		; INP:	bx:(e)si-> where to write the breakpoint
  5485                                  		; OUT:	NC if the breakpoint was hit,
  5486                                  		;	 ah = 0
  5487                                  		;	 ch = 0
  5488                                  		;	 d[reg_eip] adjusted
  5489                                  		;	 cx & 8 set if proceed point hit
  5490                                  		;	 (ZF only set if _BREAKPOINTS)
  5491                                  		;	 ZR if breakpoint after instruction was hit,
  5492                                  		;	  cx & 7 = 0
  5493                                  		;	 NZ if another breakpoint (bb) was hit (or both),
  5494                                  		;	  cx & 1 set if non-pass match (actual hit),
  5495                                  		;	   else cx & 2 set if pass match (consider as hit first,
  5496                                  		;		but dump registers next (not to silent buffer)
  5497                                  		;		and then continue execution)
  5498                                  		;	   else cx & 4 always set, indicates any match
  5499                                  		;		(including matches that should merely continue)
  5500                                  		;	  all pass points' counters stepped
  5501                                  		;	CY if the breakpoint was not hit,
  5502                                  		;	 cx = 0
  5503                                  		;	If [internalflags2] & dif2_gg_is_gg is set:
  5504                                  		;	 ah & 7Fh = status =	0 = no error,
  5505                                  		;				1 = couldn't write,
  5506                                  		;				2 = unreachable,
  5507                                  		;				3 = overwritten, al = new value
  5508                                  		;	 ah & 80h = set if error restoring point,
  5509                                  		;			else error writing point to begin with
  5510                                  		;	If that flag is clear:
  5511                                  		;	Does not return if a breakpoint cannot be written
  5512                                  		;	 or cannot be restored, jumps to cmd3 instead.
  5513                                  		; CHG:	all
  5514                                  		; STT:	ds = es = ss
  5515                                  		;	might return modeswitched (if dif2_gg_is_gg)
  5516                                  		;	might be called while modeswitched
  5517                                  proceedbreakpoint: section_of_function
  5518 000015BE F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  5519 000015C3 750D                    	jnz @F
  5520                                  
  5521 000015C5 66                      	_386_PM_o32		; mov edx, esi
  5522 000015C6 89F2                    	mov dx, si		; bx:(e)dx = segmented
  5523 000015C8 E8FBF2                  	call getlinear_d_b	; dx:ax = linear
  5524                                  
  5525 000015CB A3[0000]                	mov word [tpg_proceed_bp], ax
  5526                                  		; The following two instructions must be in this order.
  5527                                  		;  For the non-_PM build, writing to the second word
  5528                                  		;  of the breakpoint also writes to the content byte.
  5529 000015CE 8916[0200]              	mov word [tpg_proceed_bp + 2], dx
  5530                                  				; store in point
  5531                                  @@:
  5532 000015D2 C606[0800]CC            	mov byte [tpg_proceed_bp + BPSIZE - 1], 0CCh
  5533                                  				; initialise content
  5534 000015D7 E8C0FE                  	call proceed_writepoint
  5535                                  		; This call might return modeswitched.
  5536 000015DA 7308                    	jnc @F
  5537                                  
  5538 000015DC 80E47F                  	and ah, ~80h		; mark error during writing
  5539                                  
  5540 000015DF 31C9                    	xor cx, cx		; cx = 0 in case of branching
  5541 000015E1 51                      	push cx			; put the zero on the stack
  5542                                  
  5543 000015E2 EB0E                    	jmp .failure
  5544                                  
  5545                                  @@:
  5546                                  		; The run functions call resetmode.
  5547                                  %if _BREAKPOINTS
  5548 000015E4 E87900                  	call run_with_bb
  5549 000015E7 89C8                    	mov ax, cx
  5550                                  %else
  5551                                  	call run
  5552                                  	xor ax, ax
  5553                                  %endif
  5554 000015E9 50                      	push ax
  5555                                  
  5556                                  		; It's important to keep the linear address saved inbetween,
  5557                                  		; even though we save by value (as opposed to DEBUG/X G's saving
  5558                                  		; of the reference) because the selector that we used for the
  5559                                  		; access might now be invalid or (worse) point elsewhere, or
  5560                                  		; a mode change might have occured. (The latter is sometimes
  5561                                  		; handled by a specific kludge in DEBUG/X, but not always.)
  5562                                  
  5563 000015EA E89FFE                  	call proceed_writepoint_restore
  5564                                  		; This call might return modeswitched.
  5565 000015ED 7329                    	jnc @F
  5566                                  
  5567 000015EF 80CC80                  	or ah, 80h		; mark error during restoration
  5568                                  
  5569                                  .failure:
  5570                                  		; Here we may be modeswitched.
  5571 000015F2 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  5572                                  				; is it from gg ?
  5573 000015F7 7558                    	jnz .return_CY_pop_cx	; (CY) yes, return to gg
  5574                                  		; This branch may be taken while modeswitched.
  5575                                  
  5576                                  %if _PM
  5577 000015F9 E818F4                  	call resetmode
  5578                                  %endif
  5579                                  
  5580 000015FC E8B0ED                  	call put_deferred_message_silent
  5581                                  
  5582 000015FF 50                      	push ax
  5583 00001600 E8(0000)                	call silence_dump
  5584 00001603 58                      	pop ax
  5585                                  
  5586 00001604 FF36[0200]              	 push word [tpg_proceed_bp + 2]
  5587 00001608 FF36[0000]              	 push word [tpg_proceed_bp]
  5588 0000160C 8A1E[0800]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
  5589 00001610 B700                    	mov bh, 0
  5590 00001612 E8E0FE                  	call display_breakpoint_failure
  5591                                  		; This function calls resetmode.
  5592 00001615 E9(0000)                	jmp cmd3
  5593                                  
  5594                                  @@:
  5595 00001618 E87AF3                  	call get_cseip_of_possible_breakpoint
  5596                                  				; dx:ax = linear address 1 before cs:(e)ip
  5597 0000161B 7232                    	jc .return_CY_pop_cx_ax_zero
  5598                                  
  5599 0000161D 59                      	pop cx
  5600                                  %if _PM
  5601 0000161E 3916[0200]              	cmp word [tpg_proceed_bp + 2], dx
  5602                                  %else
  5603                                  	test dh, dh		; (bits 24 to 31 set. shouldn't happen)
  5604                                  	jnz .not_pp
  5605                                  	cmp byte [tpg_proceed_bp + 2], dl
  5606                                  %endif
  5607 00001622 7511                    	jne .not_pp
  5608 00001624 3906[0000]              	cmp word [tpg_proceed_bp], ax
  5609 00001628 750B                    	jne .not_pp		; is unexpected (not behind the breakpoint) -->
  5610                                  
  5611                                  		; Need to check this here, because we have to
  5612                                  		; decrement (e)ip if the breakpoint was hit.
  5613 0000162A 813E[0000][0000]        	cmp word [run_int], int3msg
  5614 00001630 7503                    	jne .not_pp		; is unexpected (not returned by interrupt 03h) -->
  5615 00001632 80C908                  	or cl, 8		; set flag: pp hit
  5616                                  
  5617                                  .not_pp:
  5618 00001635 B400                    	mov ah, 0		; set error to "no error"
  5619                                  
  5620 00001637 E319                    	jcxz .return_CY		; bb hit/pass/nonpass or pp hit ?  if no -->
  5621                                  
  5622 00001639 E895ED                  	call adjust_cseip_after_breakpoint
  5623                                  				; decrement (e)ip to point at the instruction
  5624                                  
  5625 0000163C F6C101                  	test cl, 1		; bb hit ?
  5626 0000163F 750A                    	jnz .return		; yes, return (NC, NZ) -->
  5627                                  
  5628 00001641 F6C108                  	test cl, 8		; proceed point matched ?
  5629 00001644 7506                    	jnz @F			; yes -->
  5630                                  
  5631 00001646 800E[0000]80            	setopt [internalflags2], dif2_tpg_keep_proceed_bp
  5632                                  				; flag that we should keep this proceed point
  5633                                  				; (NC, NZ)
  5634                                  .return:
  5635 0000164B C3                      	retn
  5636                                  
  5637                                  @@:
  5638                                  		; return with ax = 0, NC, ZR
  5639                                  		;
  5640                                  		; (hit proceed point, no hit bb (possibly pass/non-pass bb)
  5641 0000164C 31C0                    	xor ax, ax		; ah = 0 (NC, ZR)
  5642 0000164E C3                      	retn
  5643                                  
  5644                                  		; set ax = 0, pop cx, CY
  5645                                  .return_CY_pop_cx_ax_zero:
  5646 0000164F 31C0                    	xor ax, ax
  5647                                  
  5648                                  		; pop cx, CY (preserve ax)
  5649                                  .return_CY_pop_cx:
  5650 00001651 59                      	pop cx
  5651                                  .return_CY:
  5652 00001652 F9                      	stc
  5653 00001653 C3                      	retn
  5654                                  
  5655                                  
  5656                                  		; PPX - Get next byte in instruction stream.
  5657                                  		; INP:	bx:(e)si-> next byte
  5658                                  		; OUT:	al = next byte
  5659                                  		;	(e)si incremented
  5660                                  pp16: section_of_function
  5661                                  %if _PM
  5662 00001654 E8(0000)                	call resetmode_and_test_d_b_bit
  5663                                  %endif
  5664 00001657 1E                      	push ds
  5665 00001658 8EDB                    	mov ds, bx
  5666                                  %if _PM
  5667 0000165A 7401                    	jz .16
  5668 0000165C 67                      	a32			; use esi for lodsb
  5669                                  .16:
  5670                                  %endif
  5671 0000165D AC                      	lodsb
  5672 0000165E 1F                      	pop ds
  5673 0000165F C3                      	retn
  5674                                  		; begin loop over instruction bytes.
  5675                                  
  5676                                  
  5677                                   %if _BREAKPOINTS
  5678                                  		; Run with bb breakpoints
  5679                                  		;
  5680                                  		; OUT:	CY if another breakpoint (not a bb one) or trace hit,
  5681                                  		;	 cx = 0
  5682                                  		;	NC if a bb breakpoint hit,
  5683                                  		;	 cx & 1 set if it is an actual hit
  5684                                  		;	 else cx & 2 set if it is a pass match,
  5685                                  		;	 else it is a non-pass non-match
  5686                                  		;	 (cx & 4 always set)
  5687                                  		; STT:	might return modeswitched
  5688                                  run_with_bb:
  5689 00001660 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  5690 00001665 750C                    	jnz .no_bb
  5691                                  
  5692 00001667 F606[0300]C0            	testopt [internalflags], tt_no_bb | tt_no_bb_first
  5693 0000166C 740C                    	jz @F
  5694                                  
  5695 0000166E 8026[0300]7F            	clropt [internalflags], tt_no_bb_first
  5696                                  
  5697                                  .no_bb:
  5698 00001673 E87400                  	call run
  5699 00001676 31C9                    	xor cx, cx
  5700 00001678 F9                      	stc
  5701 00001679 C3                      	retn
  5702                                  
  5703                                  @@:
  5704                                  .gg5:
  5705                                  %if _BREAKPOINTS
  5706 0000167A E898EF                  	call bb_writepoints_init_reset
  5707                                  %endif
  5708                                  
  5709 0000167D F606[0000]10            	testopt [internalflags2], dif2_gg_first_detected
  5710 00001682 7436                    	jz .only_run		; easy case, no cseip point detected -->
  5711                                  
  5712                                  
  5713                                  		; Enter special mode: Restore cseip breakpoint content.
  5714 00001684 800E[0000]02            	setopt [internalflags2], dif2_gg_skip_non_cseip
  5715                                  
  5716 00001689 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5717 0000168C 89E5                    	mov bp, sp		; -> error info
  5718                                  
  5719 0000168E B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5720                                  				; = index above last one to restore
  5721 00001691 E84FF0                  	call bb_restorepoints_and_init_error_info
  5722 00001694 7317                    	jnc @F			; no error ? -->
  5723                                  
  5724                                  		; Error in bb_restorepoints. Try to restore other bb.
  5725                                  
  5726                                  		; Exit special mode: Handle non-cseip breakpoints again.
  5727 00001696 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
  5728                                  
  5729                                  		; Enter special mode: Skip cseip breakpoints.
  5730 0000169B 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
  5731                                  
  5732                                  		; As we already tried to restore all cseip bb points,
  5733                                  		;  here we skip these in the bb_restorepoints call.
  5734 000016A0 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5735 000016A3 E840F0                  	call bb_restorepoints
  5736                                  
  5737                                  		; Exit special mode: No longer skip cseip breakpoints.
  5738 000016A6 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
  5739                                  
  5740                                  		; The failure that led us here is already noted in the info.
  5741 000016AB EB1D                    	jmp .bb_exit
  5742                                  
  5743                                  
  5744                                  @@:
  5745                                  		; Success! Now discard the reserved error info.
  5746 000016AD 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5747                                  
  5748                                  		; Exit special mode, do not skip non-cseip breakpoints anymore.
  5749 000016B0 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
  5750                                  
  5751                                  		; Enter special mode: Skip matching/restoring cseip breakpoint.
  5752 000016B5 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
  5753                                  
  5754                                  .only_run:
  5755 000016BA E82D00                  	call run
  5756                                  .after_run:
  5757                                  
  5758                                  %if _BREAKPOINTS
  5759 000016BD 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5760 000016C0 89E5                    	mov bp, sp
  5761                                  
  5762 000016C2 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5763                                  				; = index above last one to restore
  5764 000016C5 E81BF0                  	call bb_restorepoints_and_init_error_info
  5765 000016C8 7308                    	jnc @F
  5766                                  
  5767                                  .bb_exit:
  5768 000016CA B8FFFF                  	mov ax, -1
  5769 000016CD 50                      	push ax			; (unused: ax error info)
  5770 000016CE 50                      	push ax			; cx error point index, -1 = invalid
  5771                                  
  5772 000016CF E960EF                  	jmp bb_restorepoints_exit
  5773                                  
  5774                                  
  5775                                  @@:
  5776 000016D2 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5777                                  
  5778 000016D5 E814ED                  	call bb_check_hit
  5779 000016D8 89C1                    	mov cx, ax
  5780 000016DA 9C                      	pushf
  5781                                  		; Clear all special modes. Stop specialcasing cseip breakpoint.
  5782                                  		;
  5783                                  		; This resets all the special flags for subsequent calls.
  5784 000016DB 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  5787 000016E0 9D                      	popf			; CF
  5788 000016E1 7302                    	jnc @F
  5789                                  
  5790 000016E3 F9                      	stc
  5791                                  				; cx = flags as returned by bb_check_hit
  5792 000016E4 C3                      	retn
  5793                                  
  5794                                  @@:
  5795 000016E5 E8E9EC                  	call adjust_cseip_after_breakpoint
  5796                                  				; re-execute (restored) opcode one byte in front of this
  5797 000016E8 F8                      	clc			; (NC)
  5798                                  				; cx = flags as returned by bb_check_hit
  5799 000016E9 C3                      	retn
  5800                                  %endif
  5801                                   %endif
  5802                                  %endif	; !_LOADER
  5803                                  
  5804                                  
  5805                                  		; Run - Start up the running program.
  5806                                  		;
  5807                                  		; INP:	b[eqflag], a[eqladdr] = address given behind '=' for command
  5808                                  		;	w[pspdbe] = process of debuggee
  5809                                  		;	[run2324] = interrupt handlers 23h and 24h to set
  5810                                  		;	values for registers in d[reg_eax] etc
  5811                                  		; OUT:	(_DEBUG && _DEBUGUPDATESAVE)
  5812                                  		;	 interrupt handlers' ieNext fields updated
  5813                                  		;	d[reg_eax] etc updated
  5814                                  		;	w[run_int]-> message of how execution returned
  5815                                  		;	UP, EI, high word efl = 0, es = ds = ss
  5816                                  		; CHG:	all
  5817                                  		; STT:	ds = ss
  5818                                  		;	UP
  5819                                  		;	(INP:es ignored)
  5820                                  run:
  5821 000016EA 16                      	 push ss
  5822 000016EB 07                      	 pop es
  5823                                  %if _PM
  5824 000016EC E825F3                  	call resetmode
  5825 000016EF E80A02                  	call remember_mode
  5826                                  %endif
  5827                                  %if _DELAY_BEFORE_BP
  5828 000016F2 8026[0200]7F            	clropt [internalflags3], dif3_delayed
  5829                                  %endif
  5830                                  %if !_LOADER
  5831 000016F7 8126[0000]7FF0          	clropt [internalflags2], 		dif2_tpg_have_bp | dif2_tpg_adjusted_cseip 		| dif2_tpg_do_not_adjust | dif2_bp_failure 		| dif2_tpg_keep_proceed_bp, 1
  5835 000016FD E89304                  	call seteq			; set CS:IP to '=' address
  5836                                  %endif
  5837                                  
  5838                                  %if _VXCHG
  5839 00001700 B000                    	mov al, 0			; restore debuggee screen
  5840 00001702 E8(0000)                	call swapscreen
  5841                                  %endif
  5842                                  
  5843                                  %if _ALTVID
  5844 00001705 E8D000                  	call setscreen
  5845                                  %endif
  5846                                  
  5847                                  		; For DDebugX: Do this before we install our
  5848                                  		;  exception handlers. So if an exception
  5849                                  		;  is raised then it is handled by the outer
  5850                                  		;  instance instead of our handler.
  5851                                  		; (The actual problem may be that we don't
  5852                                  		;  restore the handlers in the entrypoint
  5853                                  		;  that leads to debuggerexception.)
  5854                                  		; Also, for non-_DEBUG DebugX too, check the
  5855                                  		;  validity before setting debuggee PSP and
  5856                                  		;  int 23h, 24h so they needn't be reset.
  5857                                  %if _PM
  5858                                  		; Load segreg values into es to make sure
  5859                                  		;  they're valid. (Previously done with
  5860                                  		;  the stack pointing into the reg array.
  5861                                  		;  Better to do it now with a valid stack.)
  5862                                  		; Only done if we may be in Protected Mode.
  5863                                  		;  86 Mode allows any value to be loaded.
  5864 00001708 8E06[0000]              	mov es, word [reg_ds]
  5865 0000170C 8E06[0000]              	mov es, word [reg_ss]
  5866 00001710 8E06[0000]              _386	mov es, word [reg_fs]
  5867 00001714 8E06[0000]              _386	mov es, word [reg_gs]
  5868                                  %endif
  5869 00001718 8E06[0000]              	mov es, word [reg_es]		; last one: actual es value
  5870                                  
  5871                                  %if !_LOADER
  5872 0000171C 8B1E[0000]              	mov bx, word [pspdbe]
  5873 00001720 E8(0000)                	call setpsp			; set debuggee's PSP
  5874 00001723 E8(0000)                	call setint2324			; set debuggee's int 23/24
  5875                                  %endif
  5876                                  
  5877                                  %if _DEBUG				; set this copy's divide/trace/breakpoint ints
  5878                                   %if _TSR || _BOOTLDR || _DEVICE
  5879                                  ..@patch_tsr_quit_run:
  5880                                  	db __TEST_IMM16
  5881                                  	dw __REL16__(.skipints)
  5882                                   %endif
  5883                                   %if _DEBUG_COND
  5884                                  	testopt [internalflags6], dif6_debug_mode
  5885                                  	jz .skipints
  5886                                  	call set_interrupts
  5887                                  	jmp .skipints
  5888                                  
  5889                                  set_interrupts: equ $
  5890                                   %endif
  5891                                  	push cx
  5892                                  	push si
  5893                                  	push ax
  5894                                  	push dx
  5895                                  	push es
  5896                                  	push bx
  5897                                  	push bp
  5898                                  	push di
  5899                                  
  5900                                  %if _PM
  5901                                  	call ispm
  5902                                  	jz @F			; in PM -->
  5903                                  	testopt [internalflags], canswitchmode
  5904                                  	jz @FF			; in 86 Mode and cannot switch to PM -->
  5905                                  
  5906                                  d4	call d4message
  5907                                  d4	asciz "In run (switch mode before calling pm_set_handlers)",13,10
  5908                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  5909                                  	mov al, 0
  5910                                  	call sr_state		; save state
  5911                                  	call switchmode 	; switch to PM
  5912                                  		; ! handle_mode_changed not called here !
  5913                                  		; do not call InDOS or other functions using seg/sels
  5914                                  @@:
  5915                                  	call pm_set_handlers
  5916                                  		; ! this calls resetmode
  5917                                  @@:
  5918                                  %endif
  5919                                  
  5920                                  %if _CATCHINT06 && _DETECT95LX
  5921                                  	mov cx, word [inttab_number_variable]
  5922                                  %else
  5923                                  	mov cx, inttab_number
  5924                                  %endif
  5925                                  	jcxz .intend
  5926                                  	mov si, inttab
  5927                                  .intloop:
  5928                                  	lodsb
  5929                                  	xchg ax, dx
  5930                                  	lodsw				; get address
  5931                                  	xchg ax, dx
  5932                                  %if _DEBUGUPDATESAVE
  5933                                  	mov di, dx			; -> IISP header
  5934                                  %endif
  5935                                  
  5936                                  	call InDOS
  5937                                  	jz .int21_25
  5938                                  
  5939                                  	xor bx, bx
  5940                                  %if _PM
  5941                                  	call ispm
  5942                                  	jnz @F
  5943                                  	push dx
  5944                                  	mov dx, bx			; set segment to access (= 0)
  5945                                  	call setrmsegm			; get bx = selector configured to this
  5946                                  	pop dx
  5947                                  @@:
  5948                                  %endif
  5949                                  	mov es, bx			; => 86 Mode IVT (segment or selector)
  5950                                  %if _PM
  5951                                  	xor bx, bx			; bh = 0
  5952                                  %endif
  5953                                  	mov bl, al
  5954                                  	add bx, bx
  5955                                  	add bx, bx
  5956                                  
  5957                                  %if _DEBUGUPDATESAVE
  5958                                  	push word [ es:bx + 2 ]
  5959                                  	push word [ es:bx ]		; get vector
  5960                                  	pop word [ di + ieNext ]
  5961                                  	pop word [ di + ieNext + 2]
  5962                                  %endif
  5963                                  
  5964                                  	mov word [ es:bx ], dx
  5965                                  %if _PM
  5966                                  	push word [ pspdbg ]		; => lDEBUG_DATA_ENTRY (86 Mode seg)
  5967                                  	pop word [ es:bx + 2 ]
  5968                                  %else
  5969                                  	mov word [ es:bx + 2 ], ds	; => lDEBUG_DATA_ENTRY
  5970                                  %endif
  5971                                  	jmp short .intset
  5972                                  
  5973                                  .int21_25:
  5974                                  
  5975                                  %if _PM
  5976                                   %if _DEBUGUPDATESAVE
  5977                                  	mov ah, 35h			; get interrupt vector
  5978                                  	 push word [pspdbg]		; => lDEBUG_DATA_ENTRY
  5979                                  	dual2call _doscall_return_es_parameter_es_ds
  5980                                  	mov word [ di + ieNext ], bx
  5981                                  	 pop word [ di + ieNext + 2 ]
  5982                                   %endif
  5983                                  	mov ah, 25h			; set interrupt vector
  5984                                  	push word [pspdbg]		; => lDEBUG_DATA_ENTRY
  5985                                  	dual2call _doscall_return_es_parameter_es_ds
  5986                                  	pop ax				; (discard returned parameter)
  5987                                  %else
  5988                                   %if _DEBUGUPDATESAVE
  5989                                  	mov ah, 35h
  5990                                  	int 21h				; get vector
  5991                                  	mov word [ di + ieNext ], bx
  5992                                  	mov word [ di + ieNext + 2 ], es
  5993                                   %endif
  5994                                  	mov ah, 25h			; set interrupt vector
  5995                                  	int 21h				; ds => lDEBUG_DATA_ENTRY
  5996                                  %endif
  5997                                  .intset:
  5998                                  	loop .intloop
  5999                                  
  6000                                  .intend:
  6001                                  	pop di
  6002                                  	pop bp
  6003                                  	pop bx
  6004                                  	pop es
  6005                                  	pop dx
  6006                                  	pop ax
  6007                                  	pop si
  6008                                  	pop cx
  6009                                   %if _DEBUG_COND
  6010                                  	retn
  6011                                   %endif
  6012                                  .skipints:
  6013                                  %endif
  6014                                  
  6015                                  .2:
  6016                                  %if _RUN2_ENTRY_SECTION
  6017                                   %if _PM
  6018 00001726 E8(0000)                	call ispm
  6019 00001729 7505                    	jnz @F
  6020 0000172B FF36[0000]              	push word [cssel]
  6021 0000172F A8                      	db __TEST_IMM8			; (skip push)
  6022                                  @@:
  6023                                   %endif
  6024 00001730 16                      	push ss
  6025 00001731 B8[D000]                	mov ax, .entry
  6026 00001734 50                      	push ax
  6027 00001735 CB                      	retf
  6028                                  
  6029                                  	usesection lDEBUG_DATA_ENTRY
  6029          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6030                                  .entry:
  6031                                  %endif
  6032 000000D0 2B26[0000]              	sub sp, word [run_sp_reserve]
  6033 000000D4 8926[0000]              	mov word [run_sp], sp		; save stack position
  6034                                  
  6035                                  	; Disable this for now. The debugger uses its ss
  6036                                  	;  for 86 Mode and Protected Mode at the same area
  6037                                  	;  so it should always be valid to adjust SPSAV with
  6038                                  	;  the current run_sp, regardless of current mode.
  6039                                  	; Update: SPSAV should always hold a 86 Mode address.
  6040                                  	;  So check for our segment, not the current ss. (But
  6041                                  	;  for _PM=0 ss is always equal to word [pspdbg].)
  6042                                  	;  I assume that the original fix was intended for cases
  6043                                  	;  where the segment doesn't match our 86 Mode ss, that
  6044                                  	;  is the word [pspdbg].
  6045                                  %if !_LOADER
  6046                                  %if 1
  6047                                  	; 16.2.2021: check if saved SS is debugger's SS. If no, don't adjust saved SP.
  6048                                  	; SS may be != saved SS if debugger is stopped in protected-mode - then the
  6049                                  	; current DPMI real-mode stack may be stored in SPSAV.
  6050                                   %if _PM
  6051 000000D8 A1[0000]                	mov ax, word [pspdbg]
  6052                                   %else
  6053                                  	mov ax, ss
  6054                                   %endif
  6055 000000DB 3B063000                	cmp ax, word [SPSAV + 2]
  6056 000000DF 7508                    	jne @F
  6057                                  %endif
  6058 000000E1 2B26[0000]              	sub sp, word [spadjust]
  6059 000000E5 89262E00                	mov word [SPSAV], sp
  6060                                  @@:
  6061                                  %endif
  6062 000000E9 FA                      	cli
  6063                                  
  6064 000000EA BC[0000]                	mov sp, regs
  6065                                  %ifn _ONLY386
  6066 000000ED EB11                    	_386_jmps .386			; -->
  6067 000000EF 58                      	pop ax
  6068 000000F0 58                      	pop ax				; discard all high words
  6069 000000F1 5B                      	pop bx
  6070 000000F2 58                      	pop ax
  6071 000000F3 59                      	pop cx
  6072 000000F4 58                      	pop ax
  6073 000000F5 5A                      	pop dx
  6074 000000F6 58                      	pop ax
  6075 000000F7 58                      	pop ax				; we'll get esp later
  6076 000000F8 58                      	pop ax
  6077 000000F9 5D                      	pop bp
  6078 000000FA 58                      	pop ax
  6079 000000FB 5E                      	pop si
  6080 000000FC 58                      	pop ax
  6081 000000FD 5F                      	pop di
  6082                                  		; ds, ss, cs loaded later
  6083                                  		; es already loaded
  6084                                  %endif
  6085                                  %ifn _ONLYNON386
  6086                                   %ifn _ONLY386
  6087 000000FE EB18                    	jmp short .common
  6088                                   %endif
  6089                                  
  6090                                  .386:
  6091                                  [cpu 386]
  6092 00000100 6658                    	pop eax
  6093 00000102 665B                    	pop ebx
  6094 00000104 6659                    	pop ecx
  6095 00000106 665A                    	pop edx
  6096 00000108 58                      	pop ax
  6097 00000109 58                      	pop ax				; we'll get esp later
  6098 0000010A 665D                    	pop ebp
  6099 0000010C 665E                    	pop esi
  6100 0000010E 665F                    	pop edi
  6101                                  	; pop ax			; get ds later
  6102                                  	; pop ax			; discard high words of segment registers
  6103                                  	; pop ax			; es already loaded
  6104                                  	; pop ax
  6105                                  	; pop ax			; get ss later
  6106                                  	; pop ax
  6107                                  	; pop ax			; get cs later
  6108                                  	; pop ax
  6109 00000110 83C410                  	add sp, byte 8 * 2
  6110 00000113 0FA1                    	pop fs
  6111 00000115 58                      	pop ax
  6112 00000116 0FA9                    	pop gs
  6113                                  __CPU__
  6114                                  .common:
  6115                                  %endif
  6116 00000118 A1[0000]                	mov ax, word [reg_eax]		; restore ax (used to discard words)
  6117 0000011B 8E16[0000]              	mov ss, word [reg_ss]
  6118                                  %if _ONLYNON386
  6119                                  	mov sp, word [reg_esp]
  6120                                  %else
  6121                                  ..@patch_no386_ds_code_or_entry:
  6122 0000011F 66                      	o32			; mov esp, dword [reg_esp]
  6123 00000120 8B26[0000]              	mov sp, word [reg_esp]		; restore program stack
  6124                                  %endif
  6125 00000124 C606[0000]00            	mov byte [bInDbg], 0
  6126                                  
  6127 00000129 90<rep 3h>              	align 4, nop
  6128                                  patcharea_run:
  6129 0000012C 90<rep 20h>             .:	times 32 nop
  6130                                  .end:
  6131                                  .size equ .end - .
  6132                                  %if _RUN2_ENTRY_SECTION
  6133                                  .segment equ pspdbg
  6134                                  %else
  6135                                  .segment equ code_seg
  6136                                  %endif
  6137                                  
  6138 0000014C 66                      	_386_o32		; push dword [reg_efl]
  6139 0000014D FF36[0000]              	push word [reg_efl]
  6140 00000151 66                      	_386_o32		; push dword [reg_cs]	; high word is zero
  6141 00000152 FF36[0000]              	push word [reg_cs]
  6142 00000156 66                      	_386_o32		; push dword [reg_eip]
  6143 00000157 FF36[0000]              	push word [reg_eip]
  6144 0000015B F606[0100]02            	test byte [reg_efl+1], 2	; IF set?
  6145 00000160 8E1E[0000]              	mov ds, word [reg_ds]		; restore ds
  6146 00000164 7401                    	jz .di
  6147 00000166 FB                      	sti				; required for ring3 protected mode if IOPL==0
  6148                                  .di:
  6149                                  %if _ONLYNON386
  6150                                  	iret
  6151                                  %else
  6152                                  ..@patch_no386_iret_code_or_entry:
  6153 00000167 66                      	o32			; iretd
  6154 00000168 CF                      	iret				; jump to program
  6155                                  %endif
  6156                                  
  6157                                  ; The byte at ..@patch_no386_ds will be adjusted to a ds prefix on non-386 processors.
  6158                                  ; This does not change the following instruction's behaviour (aside from changing it
  6159                                  ; to a 16-bit instruction as intended) and insures that sp is set in the instruction
  6160                                  ; right behind the instruction that sets ss.
  6161                                  
  6162                                  ; The byte at ..@patch_no386_iret will be adjusted to an iret instruction on non-386 processors.
  6163                                  ; This avoids the NOP that would be written there if _386_o32 was used, because the iret
  6164                                  ; should follow right behind the sti instruction.
  6165                                  
  6166                                  
  6167                                  	usesection lDEBUG_DATA_ENTRY
  6167          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6168                                  
  6169                                  
  6170                                  %if _CATCHSYSREQ
  6171                                  @@:
  6172                                  	jmp far [cs:intr_sysreq.next]
  6173                                  
  6174                                  iispentry intr_sysreq, 0
  6175                                  	cmp byte [cs:bInDbg], 0
  6176                                  	jne @B
  6177                                   %if _SYSREQINT == 15h
  6178                                  	cmp ax, 8501h	; sysreq released?
  6179                                  	jne @B
  6180                                   %else
  6181                                  	pushf
  6182                                  	push cs
  6183                                  	call @B
  6184                                  	push ds
  6185                                  	push ax
  6186                                  	mov ax, 40h
  6187                                  	mov ds, ax
  6188                                  	test byte [18h], 4
  6189                                  	pop ax
  6190                                  	pop ds
  6191                                  	jnz @F
  6192                                  	iret
  6193                                  
  6194                                  @@:
  6195                                   %endif
  6196                                   %if _PM && _SYSREQ_DISABLE_INT2F_HOOK
  6197                                  	clropt [options4], opt4_int_2F_hook	; disable hooking
  6198                                   %endif
  6199                                  	mov word [cs:run_int], sysreqmsg	; remember interrupt type
  6200                                  	jmp intrtn			; jump to register saving routine
  6201                                  %endif
  6202                                  
  6203                                  
  6204                                  %if _CATCHINT08
  6205 00000169 CBEB10FFFFFFFF4B42-     iispentry intr8, 0
  6205 00000172 00EBF400<rep 7h>   
  6206                                  intr8_original: equ intr8.next
  6207 0000017C 9C                      	pushf
  6208 0000017D 2EFF1E[6C01]            	call far [cs:intr8_original]
  6209 00000182 9C                      	pushf
  6210 00000183 53                      	push bx
  6211 00000184 1E                      	push ds
  6212                                  
  6213 00000185 0E                      	 push cs
  6214 00000186 1F                      	 pop ds
  6215                                  
  6216 00000187 803E[0000]00            	cmp byte [bInDbg], 0		; in debugger ?
  6217 0000018C 7559                    	jne .reset			; yes -->
  6218                                  
  6219 0000018E F606[0000]04            	testopt [serial_flags], sf_double_ctrl_c
  6220 00000193 7408                    	jz @F
  6221                                  
  6222 00000195 C706[0000][0000]        	mov word [run_int], runint_ctrlc_msg
  6223 0000019B EB44                    	jmp @FF
  6224                                  
  6225                                  @@:
  6226 0000019D BB4000                  	mov bx, 40h
  6227 000001A0 8EDB                    	mov ds, bx
  6228 000001A2 F606170004              	test byte [17h], 4		; CTRL currently pressed ?
  6229 000001A7 0E                      	 push cs
  6230 000001A8 1F                      	 pop ds
  6231 000001A9 743C                    	jz .reset			; no -->
  6232                                  
  6233 000001AB 8B1E[0000]              	mov bx, word [intr8_limit]
  6234 000001AF 85DB                    	test bx, bx			; enabled ?
  6235 000001B1 7439                    	jz .return			; no -->
  6236 000001B3 FF06[0000]              	inc word [intr8_counter]
  6237 000001B7 391E[0000]              	cmp word [intr8_counter], bx	; default is ca 5 seconds
  6238 000001BB 722F                    	jb .return
  6239                                  
  6240 000001BD C706[0000][0000]        	mov word [run_int], int8msg
  6241 000001C3 F606[0100]80            	testopt [options], int8_disable_serial
  6242 000001C8 7417                    	jz @F
  6243 000001CA F606[0000]10            	testopt [serial_flags], sf_use_serial
  6244 000001CF 7410                    	jz @F
  6245                                  
  6246                                  		; Immediately disable use of serial I/O.
  6247 000001D1 8026[0000]EF            	clropt [serial_flags], sf_use_serial
  6248 000001D6 8026[0100]BF            	clropt [options], enable_serial
  6249 000001DB C706[0000][0000]        	mov word [run_int], int8_kbd_msg
  6250                                  
  6251                                  @@:
  6252 000001E1 1F                      	pop ds
  6253 000001E2 5B                      	pop bx
  6254 000001E3 9D                      	popf				; (in 86 Mode)
  6255 000001E4 E98D01                  	jmp intrtn
  6256                                  
  6257                                  .reset:
  6258 000001E7 8326[0000]00            	and word [intr8_counter], 0
  6259                                  .return:
  6260 000001EC 1F                      	pop ds
  6261 000001ED 5B                      	pop bx
  6262 000001EE 9D                      	popf				; (in 86 Mode)
  6263 000001EF CF                      	iret
  6264                                  %endif
  6265                                  
  6266                                  
  6267                                  %if !_LOADER
  6268                                  		; Interrupt 22h (program termination) handler.
  6269                                  int22:
  6270 000001F0 FA                      	cli
  6271                                  .cleartraceflag:
  6272 000001F1 0E                      	push cs
  6273 000001F2 1F                      	pop ds
  6274 000001F3 0E                      	push cs
  6275 000001F4 17                      	pop ss
  6276 000001F5 8B26[0000]              	mov sp, word [run_sp]	; restore running stack
  6277 000001F9 0326[0000]              	add sp, word [run_sp_reserve]
  6278 000001FD C706[0000][0000]        	mov word [run_int], progtrm	; set interrupt message
  6279 00000203 C706[0000][0000]        	mov word [lastcmd], dmycmd	; disable T/P/G auto-repeat
  6280                                  %if _PM
  6281 00000209 C606[0000]00            	mov byte [pm_2_86m_0], 0
  6282 0000020E 8026[0100]F7            	clropt [internalflags], protectedmode	; reset PM flag
  6283                                  %endif
  6284                                  %ifn _RUN_ENTRY_SECTION
  6285                                  	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  6286                                  	call entry_to_code_seg
  6287                                  	dw intrtn1_code
  6288                                  					; jump to register saving routine
  6289                                  %else
  6290 00000213 E91D02                  	jmp intrtn1_entry
  6291                                  %endif
  6292                                  %endif	; !_LOADER
  6293                                  
  6294                                  sharedentry1.hwreset:
  6295 00000216 CB                      	retf
  6296                                  
  6297                                  
  6298                                  %if !_LOADER
  6299 00000217 90                      	align 2
  6300 00000218 4A50                    	db "JP"				; signature for MS-DOS v7
  6301                                  ; This signature should be immediately before the int 1 interrupt handler
  6302                                  ;  to preserve int 1 and int 3. It was discovered by Japheth who wrote
  6303                                  ;  about it in https://bttr-software.de/forum/forum_entry.php?id=22502
  6304                                  		; Interrupt 01h (single-step interrupt) handler.
  6305 0000021A EB10FFFFFFFF4B4200-     iispentry intr1, 0, sharedentry1
  6305 00000223 EBF100<rep 7h>     
  6306                                  	lframe int
  6307 0000022C 5589E5                  	lenter
  6308 0000022F 50                      	push ax
  6309                                  
  6310                                  %ifn _PASSTF
  6311 00000230 806607FE                	clropt [bp + ?frame_fl], 100h	; clear TF (always)
  6312                                  %endif
  6313                                  
  6314 00000234 8CC8                    	mov ax, cs
  6315 00000236 394604                  	cmp word [bp + ?frame_cs], ax	; entry segment ?
  6316 00000239 7521                    	jne .if_ZR			; no --> (NZ)
  6317                                  
  6318                                  		; On the NEC V20 if we trace an int3 instruction
  6319                                  		;  or a div instruction that faults, we will
  6320                                  		;  enter our Trace Interrupt entry with the
  6321                                  		;  interrupt stack frame pointing at the first
  6322                                  		;  instruction of the int 3 or int 0 handler.
  6323                                  		; If this happens, clear the Trace Flag and
  6324                                  		;  continue running our handler.
  6325 0000023B 817E02[6C02]            	cmp word [bp + ?frame_ip], intr0
  6326 00000240 741A                    	je .if_ZR			; that one --> (ZR)
  6327 00000242 817E02[8802]            	cmp word [bp + ?frame_ip], intr3
  6328 00000247 7413                    	je .if_ZR			; that one --> (ZR)
  6329                                  
  6330                                  		; If the DOS doesn't clear the Trace Flag when
  6331                                  		;  it uses a PRA to return to, its iret will
  6332                                  		;  enable tracing and invoke our Trace Interrupt
  6333                                  		;  with the stack frame pointing to *the second*
  6334                                  		;  instruction in the PRA handler.
  6335                                  		; Like above, clear TF then run the PRA handler.
  6336                                  %if _PM
  6337 00000249 817E02[0000]            	cmp word [bp + ?frame_ip], getline_extra_int22.cleartraceflag
  6338 0000024E 740C                    	je .if_ZR			; that one --> (ZR)
  6339                                  %endif
  6340 00000250 817E02[F101]            	cmp word [bp + ?frame_ip], int22.cleartraceflag
  6341 00000255 7405                    	je .if_ZR			; that one --> (ZR)
  6342 00000257 817E02[0000]            	cmp word [bp + ?frame_ip], debug22.cleartraceflag
  6343                                  .if_ZR:
  6344 0000025C 58                      	pop ax
  6345                                  
  6346                                  %if _PASSTF
  6347                                  	jnz @F				; handle trace entry -->
  6348                                  	clropt [bp + ?frame_fl], 100h	; clear TF (only if we continue)
  6349                                  	lleave code, optimiserestoresp	; restore bp
  6350                                  	iret				; continue run if matched
  6351                                  
  6352                                  @@:
  6353                                  	lleave , optimiserestoresp	; restore bp
  6354                                  %else
  6355 0000025D 5D                      	lleave , optimiserestoresp	; restore bp (common before branch)
  6356 0000025E 7501                    	jnz @F				; handle trace entry -->
  6357 00000260 CF                      	iret				; continue run if matched
  6358                                  
  6359                                  @@:
  6360                                  %endif
  6361                                  
  6362 00000261 2EC706[0000][0000]      	mov word [cs:run_int], int1msg	; remember interrupt type
  6363 00000268 E90901                  	jmp intrtn			; jump to register saving routine
  6364                                  
  6365                                  
  6366                                  		; Interrupt 00h (divide error) handler.
  6367 0000026B 90EB10FFFFFFFF4B42-     iispentry intr0, 0, sharedentry1
  6367 00000274 00EB9F00<rep 7h>   
  6368 0000027E 2EC706[0000][0000]      	mov word [cs:run_int], int0msg	; remember interrupt type
  6369 00000285 E9EC00                  	jmp intrtn			; jump to register saving routine
  6370                                  
  6371                                  
  6372                                  
  6373                                  		; Interrupt 03h (breakpoint interrupt) handler.
  6374 00000288 EB10FFFFFFFF4B4200-     iispentry intr3, 0, sharedentry1
  6374 00000291 EB8300<rep 7h>     
  6375 0000029A 2EC706[0000][0000]      	mov word [cs:run_int], int3msg	; remember interrupt type
  6376                                  %if _CATCHINT06
  6377 000002A1 E9D000                  	jmp intrtn			; jump to register saving routine
  6378                                  
  6379                                  
  6380                                  		; Interrupt 06h (invalid opcode) handler.
  6381 000002A4 EB10FFFFFFFF4B4200-     iispentry intr6, 0, sharedentry2
  6381 000002AD EB1100<rep 7h>     
  6382 000002B6 2EC706[0000][0000]      	mov word [cs:run_int], int6msg	; remember interrupt type
  6383                                  %endif
  6384 000002BD E9B400                  	jmp intrtn			; jump to register saving routine
  6385                                  %endif	; !_LOADER
  6386                                  
  6387                                  
  6388                                  sharedentry2.hwreset:
  6389 000002C0 CB                      	retf
  6390                                  
  6391                                  
  6392                                  %if _CATCHINT07
  6393                                  		; Interrupt 07h (no x87 present on 286+) handler.
  6394                                  iispentry intr7, 0, sharedentry2
  6395                                  	mov word [cs:run_int], int7msg	; remember interrupt type
  6396                                  	cmp byte [cs:bInDbg], 0
  6397                                  	jne r86m_debugger_exception
  6398                                  	jmp intrtn			; jump to register saving routine
  6399                                  %endif
  6400                                  
  6401                                  %if _CATCHINT0C
  6402                                  		; Interrupt 0Ch (stack fault in R86M, or IRQ) handler.
  6403 000002C1 90EB10FFFFFFFF4B42-     iispentry intr0C, 0, sharedentry2
  6403 000002CA 00EBF300<rep 7h>   
  6404                                   %if _MCLOPT
  6405                                  	cmp byte [cs:master_pic_base], 20h
  6406                                  	jae @F
  6407                                   %endif
  6408 000002D4 50                      	push ax
  6409 000002D5 B00B                    	mov al, 0Bh			; request In-Service Register (ISR)
  6410 000002D7 E620                    	out 20h, al			; from primary PIC
  6411 000002D9 E420                    	in al, 20h			; read the ISR
  6412 000002DB A810                    	test al, 1_0000b		; IRQ #4 occurred ?
  6413 000002DD 58                      	pop ax
  6414 000002DE 7515                    	jnz .notours			; yes, (likely) not a stack fault -->
  6415                                  @@:
  6416 000002E0 2EC706[0000][0000]      	mov word [cs:run_int], int0Cmsg	; remember interrupt type
  6417 000002E7 2E803E[0000]00          	cmp byte [cs:bInDbg], 0
  6418 000002ED 7403E910FD              	jne r86m_debugger_exception
  6419 000002F2 E97F00                  	jmp intrtn			; jump to register saving routine
  6420                                  
  6421                                  .notours:
  6422 000002F5 2EFF2E[C402]            	jmp far [cs:.next]
  6423                                  %endif
  6424                                  %if _CATCHINT0D
  6425                                  
  6426                                  
  6427                                  		; Interrupt 0Dh (general protection fault in R86M, or IRQ) handler.
  6428 000002FA EB10FFFFFFFF4B4200-     iispentry intr0D, 0, sharedentry2
  6428 00000303 EBBB00<rep 7h>     
  6429                                   %if _MCLOPT
  6430                                  	cmp byte [cs:master_pic_base], 20h
  6431                                  	jae @F
  6432                                   %endif
  6433 0000030C 50                      	push ax
  6434 0000030D B00B                    	mov al, 0Bh			; request In-Service Register (ISR)
  6435 0000030F E620                    	out 20h, al			; from primary PIC
  6436 00000311 E420                    	in al, 20h			; read the ISR
  6437 00000313 A820                    	test al, 10_0000b		; IRQ #5 occurred ?
  6438 00000315 58                      	pop ax
  6439 00000316 7514                    	jnz .notours			; yes, (likely) not a GPF -->
  6440                                  @@:
  6441 00000318 2EC706[0000][0000]      	mov word [cs:run_int], int0Dmsg	; remember interrupt type
  6442 0000031F 2E803E[0000]00          	cmp byte [cs:bInDbg], 0
  6443 00000325 7403E9D8FC              	jne r86m_debugger_exception
  6444 0000032A EB48                    	jmp intrtn			; jump to register saving routine
  6445                                  
  6446                                  .notours:
  6447 0000032C 2EFF2E[FC02]            	jmp far [cs:.next]
  6448                                  %endif
  6449                                  %if _CATCHINT18
  6450                                  		; Interrupt 18h (diskless boot hook) handler.
  6451 00000331 90EB10FFFFFFFF4B42-     iispentry intr18, 0, sharedentry3
  6451 0000033A 00EB7900<rep 7h>   
  6452 00000344 2EC706[0000][0000]      	mov word [cs:run_int], int18msg	; remember interrupt type
  6453                                  %endif
  6454                                  %if _CATCHINT19
  6455 0000034B EB27                    	jmp intrtn			; jump to register saving routine
  6456                                  
  6457                                  
  6458                                  		; Interrupt 19h (boot load) handler.
  6459 0000034D 90EB10FFFFFFFF4B42-     iispentry intr19, 0, sharedentry3
  6459 00000356 00EB5D00<rep 7h>   
  6460 00000360 2EC706[0000][0000]      	mov word [cs:run_int], int19msg	; remember interrupt type
  6461 00000367 2EC706[0000][0000]      	mov word [cs:lastcmd], dmycmd	; disable T/P/G auto-repeat
  6462 0000036E 2E8026[0300]FE          	clropt [cs:internalflags2], dif2_boot_loaded_kernel
  6463                                  %endif
  6464                                  
  6465                                  		; Common interrupt routine.
  6466                                  
  6467                                  %if !_LOADER
  6468                                  		; Housekeeping.
  6469                                  intrtn:
  6470 00000374 FA                      	cli				; just in case
  6471 00000375 2E8F06[0000]            	pop word [cs:reg_eip]		; recover things from stack
  6472 0000037A 2E8F06[0000]            	pop word [cs:reg_cs]
  6473 0000037F 2E8F06[0000]            	pop word [cs:reg_efl]
  6474 00000384 2E8C1E[0000]            	mov word [cs:reg_ds], ds	; ! word-aligned (AC flag)
  6475 00000389 2EA3[0000]              	mov word [cs:reg_eax], ax	; ! word-aligned (AC flag)
  6476 0000038D 8CC8                    	mov ax, cs
  6477 0000038F 8ED8                    	mov ds, ax			; => lDEBUG_DATA_ENTRY
  6478                                  
  6479 00000391 90<rep 3h>              	align 4, nop
  6480                                  patcharea_intrtn:
  6481 00000394 90<rep 20h>             .:	times 32 nop
  6482                                  .end:
  6483                                  .size equ .end - .
  6484                                  .segment equ pspdbg
  6485                                  
  6486                                  %ifn _RUN_ENTRY_SECTION
  6487                                  	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  6488                                  	call entry_to_code_seg
  6489                                  	dw intrtn_code
  6490                                  		; To avoid delaying the code segment switch, we use the client's
  6491                                  		;  stack here to call (jump) via entry_to_code_seg.
  6492                                  %else
  6493 000003B4 EB01                    	jmp intrtn_entry
  6494                                  %endif
  6495                                  
  6496                                  sharedentry3.hwreset:
  6497 000003B6 CB                      	retf
  6498                                  
  6499                                  
  6500                                  %ifn _RUN_ENTRY_SECTION
  6501                                  	usesection lDEBUG_CODE
  6502                                  
  6503                                  	code_insure_low_byte_not_0CCh
  6504                                  intrtn_code:
  6505                                  %else
  6506                                  	usesection lDEBUG_DATA_ENTRY
  6506          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6507                                  intrtn_entry:
  6508                                  %endif
  6509                                  
  6510                                  %if _PM
  6511 000003B7 C606[0000]00            	mov byte [pm_2_86m_0], 0
  6512 000003BC 8026[0100]F7            	clropt [internalflags], protectedmode	; reset PM flag
  6513                                  .from_installdpmi:
  6514                                  %endif
  6515 000003C1 8C16[0000]              	mov word [reg_ss], ss	; save stack position
  6516 000003C5 8326[0200]00            _386	and word [reg_eip+2], byte 0	; we're from real mode
  6517 000003CA 66                      	_386_o32		; mov dword [reg_esp], esp
  6518 000003CB 8926[0000]              	mov word [reg_esp], sp
  6519 000003CF 8ED0                    	mov ss, ax		; mov ss, cs	; (don't use the stack here)
  6520                                  
  6521                                  %if _PM
  6522 000003D1 EB0D                    	jmp @F
  6523                                  
  6524                                  %ifn _RUN_ENTRY_SECTION
  6525                                  intrtn2_code:				; <--- entry protected mode
  6526                                  %else
  6527                                  intrtn2_entry:				; <--- entry protected mode
  6528                                  %endif
  6529 000003D3 368C1E[0000]            	mov word [ss:reg_ds], ds	; ! word-aligned (AC flag)
  6530 000003D8 36A3[0000]              	mov word [ss:reg_eax], ax	; ! word-aligned (AC flag)
  6531 000003DC 8CD0                    	mov ax, ss
  6532 000003DE 8ED8                    	mov ds, ax		; mov ds, ss
  6533                                  @@:
  6534                                  %endif
  6535 000003E0 B80200                  	mov ax, 2
  6536                                  %ifn _ONLY386
  6537 000003E3 EB1A                    	_386_jmps .386			; -->
  6538 000003E5 BC[0200]                	mov sp, reg_es+2
  6539 000003E8 06                      	push es
  6540                                  	; sub sp, ax
  6541                                  	; sub sp, ax			; ds already saved
  6542                                  	; sub sp, ax			; don't overwrite high word of di
  6543 000003E9 83EC06                  	sub sp, byte 3*2
  6544 000003EC 57                      	push di
  6545 000003ED 29C4                    	sub sp, ax
  6546 000003EF 56                      	push si
  6547 000003F0 29C4                    	sub sp, ax
  6548 000003F2 55                      	push bp
  6549                                  	; sub sp, ax
  6550                                  	; sub sp, ax			; sp already saved
  6551                                  	; sub sp, ax
  6552 000003F3 83EC06                  	sub sp, byte 3*2
  6553 000003F6 52                      	push dx
  6554 000003F7 29C4                    	sub sp, ax
  6555 000003F9 51                      	push cx
  6556 000003FA 29C4                    	sub sp, ax
  6557 000003FC 53                      	push bx
  6558                                  %endif
  6559                                  %ifn _ONLYNON386
  6560                                   %ifn _ONLY386
  6561 000003FD EB34                    	jmp short .common
  6562                                   %endif
  6563                                  
  6564                                  .386:
  6565                                  [cpu 386]
  6566 000003FF 66BC[02000000]          	mov esp, reg_gs+2
  6567 00000405 0FA8                    	push gs
  6568 00000407 29C4                    	sub sp, ax			; don't overwrite high words of segments
  6569 00000409 0FA0                    	push fs
  6570                                  	; sub sp, ax
  6571                                  	; sub sp, ax			; cs already saved
  6572                                  	; sub sp, ax
  6573                                  	; sub sp, ax			; ss already saved
  6574                                  	; sub sp, ax
  6575 0000040B 83EC0A                  	sub sp, byte 5*2
  6576 0000040E 06                      	push es
  6577                                  	; sub sp, ax
  6578                                  	; sub sp, ax			; ds already saved
  6579 0000040F 83EC04                  	sub sp, byte 2*2
  6580 00000412 6657                    	push edi
  6581 00000414 6656                    	push esi
  6582 00000416 6655                    	push ebp
  6583                                  	; sub sp, ax
  6584                                  	; sub sp, ax			; sp already saved
  6585 00000418 83EC04                  	sub sp, byte 2*2
  6586 0000041B 6652                    	push edx
  6587 0000041D 6651                    	push ecx
  6588 0000041F 669C                    	 pushfd				; (this overwrites reg_ebx)
  6589 00000421 01C4                    	 add sp, ax			; discard low word of efl
  6590 00000423 8F06[0200]              	 pop word [reg_efl+2]
  6591 00000427 6A00                    	 push 0
  6592 00000429 9C                      	 pushf				; (this also overwrites reg_ebx)
  6593 0000042A 669D                    	 popfd				; clear high word of efl inside debugger (resets AC flag)
  6594 0000042C 6653                    	push ebx
  6595 0000042E A1[0000]                	mov ax, word [reg_eax]		; restore ax
  6596 00000431 6650                    	push eax			; so we don't overwrite it with 2 here
  6597                                  __CPU__
  6598                                  .common:
  6599                                  %endif
  6600                                  
  6601                                  %ifn _RUN_ENTRY_SECTION
  6602                                  	code_insure_low_byte_not_0CCh
  6603                                  		; Clean up.
  6604                                  intrtn1_code:
  6605                                  %else
  6606                                  intrtn1_entry:
  6607                                  %endif
  6608 00000433 66                      	_386_o32		; mov esp, dword [run_sp]
  6609 00000434 8B26[0000]              	mov sp, word [run_sp]		; restore running stack
  6610 00000438 0326[0000]              	add sp, word [run_sp_reserve]
  6611 0000043C FC                      	cld				; clear direction flag
  6612 0000043D FB                      	sti				; interrupts back on
  6613                                  
  6614                                  %if _SYMBOLIC
  6615                                  	clropt [internalflags2], dif2_xms_detection_done
  6616                                  		; Re-detect XMS after running.
  6617                                  		;
  6618                                  		; The actual detection is done in symbol access functions,
  6619                                  		;  which are only called once all breakpoints are restored.
  6620                                  %endif
  6621                                  
  6622                                  %if _RUN_ENTRY_SECTION
  6623 0000043E E8(0000)                	call entry_to_code_segsel
  6624 00000441 [3617]                  	dw .code
  6625                                  
  6626                                  	usesection lDEBUG_CODE
  6626          ------------------       note: usesection lDEBUG_CODE
  6627                                  .code:
  6628                                  %endif
  6629                                  
  6630                                  %if _PM
  6631 00001736 E8E900                  	call handle_mode_changed
  6632                                  %endif
  6633                                  
  6634 00001739 E859F2                  	call get_cseip_of_possible_breakpoint
  6635                                  		; Initialise this here. This means we do not need to call
  6636                                  		;  resetmode between proceed_wp and bb_wp and gg_wp. If
  6637                                  		;  more than one point needs to switch modes this avoids
  6638                                  		;  repeated modeswitching back and forth.
  6639                                  
  6640                                  %if _DEBUG				; reset to next copy's divide/trace/breakpoint ints
  6641                                   %if _DEBUG_COND
  6642                                  	testopt [internalflags6], dif6_debug_mode
  6643                                  	jz .skipints
  6644                                  	call reset_interrupts
  6645                                  	jmp .skipints
  6646                                  
  6647                                  reset_interrupts: equ $
  6648                                   %endif
  6649                                  	push cx
  6650                                  	push si
  6651                                  	push di
  6652                                  	push ax
  6653                                  	push bx
  6654                                  	push dx
  6655                                  	push bp
  6656                                  
  6657                                  %if _PM
  6658                                  	call ispm
  6659                                  	jz @F			; in PM -->
  6660                                  	testopt [internalflags], canswitchmode
  6661                                  	jz @FF			; in 86 Mode and cannot switch to PM -->
  6662                                  
  6663                                  d4	call d4message
  6664                                  d4	asciz "In intrtn1_code (switch mode before calling pm_reset_handlers)",13,10
  6665                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  6666                                  	mov al, 0
  6667                                  	call sr_state		; save state
  6668                                  	call switchmode 	; switch to PM
  6669                                  		; ! handle_mode_changed not called here !
  6670                                  		; do not call InDOS or other functions using seg/sels
  6671                                  @@:
  6672                                  	call pm_reset_handlers
  6673                                  		; ! this calls resetmode
  6674                                  @@:
  6675                                  
  6676                                  	numdef OVERRIDE_BUILD_PM_DEBUG, 0
  6677                                   %if ! _CATCHPMINT214C && ! _OVERRIDE_BUILD_PM_DEBUG
  6678                                    %fatal Cannot build DDEBUGX: handler switching without Int21.4C hook untested
  6679                                   %endif
  6680                                  %endif
  6681                                  
  6682                                  %if CATCHINTAMOUNT
  6683                                  %if _CATCHINT06 && _DETECT95LX
  6684                                  	mov cx, word [inttab_number_variable]
  6685                                  %else
  6686                                  	mov cx, inttab_number
  6687                                  %endif
  6688                                  	jcxz .intend
  6689                                  	mov si, inttab
  6690                                  	mov dx, -1			; always force
  6691                                  .nextint:
  6692                                  	lodsb
  6693                                  	xchg ax, bx			; bl = number
  6694                                  	lodsw				; si -> list
  6695                                  	xchg ax, si			; si -> entry, ax -> list
  6696                                  	xchg ax, bx			; al = number, bx -> list
  6697                                  	call UnhookInterruptForce
  6698                                  	xchg bx, si			; si -> list
  6699                                  	loop .nextint
  6700                                  
  6701                                  .intend:
  6702                                  %endif
  6703                                  
  6704                                  	pop bp
  6705                                  	pop dx
  6706                                  	pop bx
  6707                                  	pop ax
  6708                                  	pop di
  6709                                  	pop si
  6710                                  	pop cx
  6711                                   %if _DEBUG_COND
  6712                                  	retn
  6713                                   %endif
  6714                                  .skipints:
  6715                                  %endif
  6716                                  
  6717 0000173C 8026[0100]FE            	clropt [reg_efl], 100h		; clear TF
  6718                                  
  6719 00001741 E8(0000)                	call getpsp
  6720 00001744 891E[0000]              	mov word [pspdbe], bx
  6721                                  
  6722 00001748 E8(0000)                	call getint2324			; save debuggee's int 23/24, set debugger's int 23/24
  6723                                  
  6724 0000174B 16                      	 push ss
  6725 0000174C 07                      	 pop es
  6726 0000174D E8(0000)                	call setpspdbg			; set PSP of debugger
  6727                                  
  6728 00001750 800E[0100]30            	setopt [internalflags], debuggerA20|debuggeeA20	; assume A20 is on
  6729                                  %if _PM
  6730 00001755 E8(0000)                	call ispm
  6731 00001758 7420                    	jz .a20done			; assume A20 on. (is this the right thing to do?)
  6732                                  %endif
  6733 0000175A 06                      	push es
  6734 0000175B 1E                      	push ds
  6735 0000175C 57                      	push di
  6736 0000175D 56                      	push si
  6737 0000175E 51                      	push cx
  6738 0000175F 31F6                    	xor si, si
  6739 00001761 8EDE                    	mov ds, si			; ds = 0000h
  6740 00001763 4E                      	dec si
  6741 00001764 8EC6                    	mov es, si			; es = FFFFh
  6742 00001766 46                      	inc si				; ds:si = 0000h:0000h =  00000h
  6743 00001767 BF1000                  	mov di, 0010h			; es:di = FFFFh:0010h = 100000h (same address if it overflows)
  6744 0000176A 89F9                    	mov cx, di			; 32 byte (16 = 10h word)
  6745 0000176C F3A7                    	repe cmpsw			; compare them and assume A20 line switched off if same
  6746 0000176E 59                      	pop cx
  6747 0000176F 5E                      	pop si
  6748 00001770 5F                      	pop di
  6749 00001771 1F                      	pop ds
  6750 00001772 07                      	pop es
  6751 00001773 7505                    	jne .a20done			; not equal, A20 line is switched on -->
  6752                                  					; if equal, the A20 line is probably switched off
  6753 00001775 8026[0100]CF            	clropt [internalflags], debuggerA20|debuggeeA20	; assume A20 is off
  6754                                  
  6755                                  %if 0 ;_LOCALENABLEA20
  6756                                  	; This doesn't serve any particular reason if we have no business accessing the HMA.
  6757                                  	; What's more important is that the dump, assemble, and disassemble commands *should*
  6758                                  	; use a disabled A20 if it is disabled to the debuggee. Thus, enabling A20 belongs, if
  6759                                  	; at all, into getsegmented (similar to the switch to PM) as there may be breakpoints in
  6760                                  	; the HMA that we need to reset.
  6761                                   %if _GUARD_86M_INT2F
  6762                                  	push es
  6763                                  	xor ax, ax
  6764                                  	mov es, ax			; (only used in 86 Mode)
  6765                                  	mov ax, [es:2Fh * 4]
  6766                                  	cmp ax, -1
  6767                                  	je @F			; --> (ZR)
  6768                                  	or ax, [es:2Fh * 4 + 2]
  6769                                  @@:
  6770                                  	pop es
  6771                                  	jz @F
  6772                                   %endif
  6773                                  	mov ax, 4300h
  6774                                  	int 2Fh				; XMS v2 installation check
  6775                                  	cmp al, 80h			; installed ?
  6776                                  	jne .a20done			; no -->
  6777                                  	mov ax, 4310h
  6778                                  	int 2Fh				; get entry
  6779                                  	mov ah, 05h
  6780                                  	push cs
  6781                                  	call callfaresbx		; local enable A20
  6782                                  	push ds
  6783                                  	pop es
  6784                                  	dec ax
  6785                                  	jnz .a20done			; not able to enable A20 -->
  6786                                  		; actually check here to insure it is on?
  6787                                  	setopt [internalflags], debuggerA20	; our A20 is on
  6788                                  @@:
  6789                                  %endif
  6790                                  .a20done:
  6791                                  
  6792 0000177A C606[0000]01            	mov byte [bInDbg], 1
  6793                                  %if _CATCHINT19
  6794 0000177F 813E[0000][0000]        	cmp word [run_int], int19msg
  6795 00001785 7505                    	jne @F
  6796 00001787 800E[0200]20            	setopt [internalflags3], dif3_gotint19
  6797                                  %endif
  6798                                  @@:
  6799 0000178C 813E[0000][0000]        	cmp word [run_int], progtrm
  6800 00001792 7505                    	jnz @F
  6801 00001794 800E[0200]80            	setopt [internalflags], attachedterm
  6802                                  @@:
  6803                                  
  6804                                  %if _FORCETEXT
  6805                                  	call checkgfx		; see if current mode is gfx, set to text if yes
  6806                                  %endif
  6807                                  
  6808                                  %if _VXCHG
  6809 00001799 B001                    	mov al, 1		; restore debugger screen
  6810 0000179B E8(0000)                	call swapscreen
  6811                                   %ifn _VXCHGBIOS
  6812 0000179E 06                      	push es
  6813 0000179F B84000                  	mov ax, 0040h
  6814 000017A2 8EC0                    	mov es, ax
  6815 000017A4 26A08400                	mov al, [es:84h]	; did the number of screen rows change?
  6816 000017A8 268A3E6200              	mov bh, [es:62h]
  6817 000017AD 883E[0000]              	mov [vpage], bh
  6818 000017B1 3A06[0000]              	cmp al, [vrows]
  6819 000017B5 A2[0000]                	mov [vrows], al
  6820 000017B8 7419                    	jz @F
  6821                                  
  6822 000017BA F606[0000]01            	testopt [internalflags6], dif6_vv_mode
  6823 000017BF 7412                    	jz @F
  6824                                  
  6825 000017C1 88C6                    	mov dh, al		; yes. we cannot fully restore, but at least
  6826 000017C3 B200                    	mov dl, 0		;  clear bottom line to ensure the debugger displays
  6827                                  				;  will be seen
  6828 000017C5 B402                    	mov ah, 2		; set cursor position
  6829 000017C7 CD10                    	int 10h
  6830 000017C9 B307                    	mov bl, 7		; BH=video page, BL=attribute
  6831 000017CB B95000                  	mov cx, 80		; CX=columns
  6832 000017CE B82009                  	mov ax, 0920h		; AL=char to display
  6833 000017D1 CD10                    	int 10h
  6834                                  @@:
  6835 000017D3 07                      	pop es
  6836                                   %else
  6837                                  ;--- with page flips, there are problems with many BIOSes:
  6838                                  ;--- the debugger displays may get the color of the debuggee!
  6839                                  ;--- if there's any trick to convince the BIOS not to do this,
  6840                                  ;--- implement it here!
  6841                                  	mov byte [vpage], 1
  6842                                   %endif
  6843                                  %endif
  6844                                  
  6845                                  %if _ALTVID
  6846 000017D4 E80100                  	call setscreen
  6847                                  %endif
  6848                                  
  6849 000017D7 C3                      	retn
  6850                                  
  6851                                  %if 0 ;_LOCALENABLEA20
  6852                                  callfaresbx:
  6853                                  	push es
  6854                                  	push bx
  6855                                  	retf
  6856                                  %endif
  6857                                  %endif	; !_LOADER
  6858                                  
  6859                                  
  6860                                  %if _ALTVID
  6861                                  
  6862                                  ;--- switch to debugger/debuggee screen with option /2.
  6863                                  ;--- since DOS/BIOS is used for output, there's no guarantee that it will work.
  6864                                  
  6865                                  setscreen:
  6866 000017D8 C3                      	retn	; will be patched to "push ds" if "/2" cmdline switch and second adapter exists
  6867                                  		; (SMC in section lDEBUG_CODE)
  6868 000017D9 8B16[0000]              	mov dx, [oldcrtp]
  6869 000017DD 8B1E[0000]              	mov bx, [oldcols]
  6870 000017E1 A1[0000]                	mov ax, [oldmr]
  6871 000017E4 B94000                  	mov cx, 0040h         ; 0040h is supposed to work in both rm/pm
  6872 000017E7 8ED9                    	mov ds, cx
  6873 000017E9 368B0E[0000]            	mov cx, [ss:oldcsrpos]
  6874 000017EE 80261000CF              	and byte [10h], ~ 30h
  6875 000017F3 80FAB4                  	cmp dl, 0B4h
  6876 000017F6 7505                    	jnz @F
  6877 000017F8 800E100030              	or  byte [10h], 30h
  6878                                  @@:
  6879 000017FD 871E4A00                	xchg bx, [4Ah]
  6880 00001801 870E5000                	xchg cx, [50h]
  6881 00001805 87166300                	xchg dx, [63h]
  6882 00001809 86064900                	xchg al, [49h]
  6883 0000180D 86268400                	xchg ah, [84h]
  6884 00001811 1F                      	pop ds
  6885 00001812 8916[0000]              	mov [oldcrtp], dx
  6886 00001816 890E[0000]              	mov [oldcsrpos], cx
  6887 0000181A 891E[0000]              	mov [oldcols], bx
  6888 0000181E A3[0000]                	mov [oldmr], ax
  6889 00001821 C3                      	retn
  6890                                  %endif
  6891                                  
  6892                                  
  6893                                  %if _FORCETEXT
  6894                                  checkgfx:
  6895                                  	mov dx, 3CEh		; see if in graphics mode
  6896                                  	in al, dx
  6897                                  	mov bl, al
  6898                                  	mov al, 6
  6899                                  	out dx, al
  6900                                  	inc dx
  6901                                  	in al, dx
  6902                                  	xchg bl, al
  6903                                  	dec dx
  6904                                  	out dx, al
  6905                                  	test bl, 1
  6906                                  	jz @F
  6907                                  	mov ax, 0003h
  6908                                  	int 10h
  6909                                  @@:
  6910                                  	retn
  6911                                  %endif
  6912                                  
  6913                                  
  6914                                  %if _PM
  6915                                  		; INP:	flag for PM
  6916                                  		;	flag for prior PM (from remember_mode)
  6917                                  		;	flag for modeswitched (set if in modeswitching)
  6918                                  		; OUT:	seg/sels initialised for new mode, if changed
  6919                                  handle_mode_changed:
  6920 00001822 BE[0000]                	mov si, convsegs
  6921 00001825 B9[0000]                	mov cx, convsegs.amount
  6922                                  
  6923 00001828 E8(0000)                	call ispm
  6924 0000182B 7503E98600              	jz .now_pm
  6925                                  [cpu 286]
  6926                                  .now_86m:
  6927 00001830 F606[0200]40            	testopt [internalflags3], dif3_prior_pm
  6928 00001835 7503E9C200              	jz .from_no_change
  6929                                  %if _MMXSUPP && _MMX_REDETECT
  6930 0000183A E8CF00                  	call mmx_redetect
  6931                                  %endif
  6932                                  .from_pm_now_86m:
  6933                                  .from_pm_now_86m.loop:
  6934 0000183D AD                      	lodsw
  6935 0000183E 97                      	xchg ax, di
  6936 0000183F 81FE[0000]              	cmp si, convsegs.end_fixed
  6937 00001843 770A                    	ja @F
  6938 00001845 8B5502                  	mov dx, word [di + soaSegment]
  6939 00001848 8915                    	mov word [di + soaSegSel], dx
  6940 0000184A E2F1                    	loop .from_pm_now_86m.loop
  6941 0000184C E9AD00                  	jmp .from_done_change
  6942                                  
  6943                                  @@:
  6944                                  		; We want to switch modes to get the segment bases.
  6945                                  		;  First check we aren't already modeswitched.
  6946 0000184F F606[0200]08            	testopt [internalflags], modeswitched
  6947 00001854 7403E9A300              	jnz .from_done_change		; cancel this -->
  6948                                  
  6949 00001859 F606[0200]04            	testopt [internalflags], canswitchmode
  6950 0000185E 7510                    	jnz @FF
  6951 00001860 EB02                    	jmp @F
  6952                                  
  6953                                  	numdef OVERRIDE_BUILD_PM_HANDLE_SWITCH, 0
  6954                                   %if ! _CATCHPMINT214C && ! _OVERRIDE_BUILD_PM_HANDLE_SWITCH
  6955                                    %fatal Cannot build DEBUGX: handle mode changed without Int21.4C will fail
  6956                                   %endif
  6957                                  
  6958                                  
  6959                                  .from_pm_now_86m.loop.nonfixed.nomodeswitch:
  6960 00001862 AD                      	lodsw
  6961 00001863 97                      	xchg ax, di
  6962                                  @@:
  6963 00001864 31D2                    	xor dx, dx
  6964 00001866 895502                  	mov word [di + soaSegment], dx
  6965 00001869 8915                    	mov word [di + soaSegSel], dx
  6966 0000186B E2F5                    	loop .from_pm_now_86m.loop.nonfixed.nomodeswitch
  6967 0000186D E98C00                  	jmp .from_done_change
  6968                                  
  6969                                  @@:
  6970 00001870 51                      	push cx
  6971 00001871 57                      	push di
  6972 00001872 56                      	push si
  6973                                  d4	call d4message
  6974                                  d4	asciz "In intrtn1_code.from_pm_now_86m (switching modes to access selectors)",13,10
  6975 00001873 800E[0200]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  6976 00001878 B000                    	mov al, 0
  6977 0000187A E872F1                  	call sr_state			; save state
  6978 0000187D E835F1                  	call switchmode 		; switch to PM
  6979                                  		; ! handle_mode_changed not called here !
  6980                                  		; do not call InDOS or other functions using seg/sels
  6981 00001880 5E                      	pop si
  6982 00001881 5F                      	pop di
  6983 00001882 EB03                    	jmp @F
  6984                                  
  6985                                  .from_pm_now_86m.loop.nonfixed:
  6986 00001884 AD                      	lodsw
  6987 00001885 97                      	xchg ax, di
  6988 00001886 51                      	push cx
  6989                                  @@:
  6990 00001887 31DB                    	xor bx, bx
  6991 00001889 875D04                  	xchg bx, word [di + soaSelector]
  6992 0000188C B80600                  	mov ax, 0006h
  6993 0000188F CD31                    	int 31h
  6994 00001891 7214                    	jc @F				; fail -->
  6995 00001893 F6C20F                  	test dl, 15
  6996 00001896 750F                    	jnz @F				; not on a segment boundary -->
  6997 00001898 F7C1F0FF                	test cx, 0FFF0h
  6998 0000189C 7509                    	jnz @F				; >= 1024 KiB -->
  6999 0000189E C1EA04                  	shr dx, 4
  7000 000018A1 C1E10C                  	shl cx, 12
  7001 000018A4 09CA                    	or dx, cx
  7002 000018A6 A9                      	db __TEST_IMM16			; (skip xor)
  7003                                  @@:
  7004 000018A7 31D2                    	xor dx, dx			; if no valid segment
  7005 000018A9 895502                  	mov word [di + soaSegment], dx
  7006 000018AC 59                      	pop cx
  7007 000018AD 8915                    	mov word [di + soaSegSel], dx
  7008 000018AF E2D3                    	loop .from_pm_now_86m.loop.nonfixed
  7009 000018B1 E860F1                  	call resetmode			; ! only if we did the switch
  7010                                  		; Note: This recursively calls this function,
  7011                                  		;  handle_mode_changed. Because the modeswitched
  7012                                  		;  flag is set during this call, this only re-
  7013                                  		;  initialises the fixed seg/sels with the segment
  7014                                  		;  values. That is redundant but does no harm.
  7015 000018B4 EB46                    	jmp .from_done_change
  7016                                  __CPU__
  7017                                  
  7018                                  .now_pm:
  7019 000018B6 F606[0200]40            	testopt [internalflags3], dif3_prior_pm
  7020 000018BB 753F                    	jnz .from_no_change
  7021                                  %if _MMXSUPP && _MMX_REDETECT
  7022 000018BD E84C00                  	call mmx_redetect
  7023                                  %endif
  7024                                  .from_86m_now_pm:
  7025                                  .from_86m_now_pm.loop:
  7026 000018C0 AD                      	lodsw
  7027 000018C1 97                      	xchg ax, di
  7028 000018C2 81FE[0000]              	cmp si, convsegs.end_fixed
  7029 000018C6 7716                    	ja @F
  7030                                  
  7031 000018C8 8B4504                  	mov ax, word [di + soaSelector]
  7032 000018CB 85C0                    	test ax, ax
  7033 000018CD 750B                    	jnz .no_dosdata_change
  7034 000018CF 8B5D02                  	mov bx, word [di + soaSegment]
  7035 000018D2 B80200                  	mov ax, 0002h
  7036 000018D5 CD31                    	int 31h
  7037 000018D7 894504                  	mov word [di + soaSelector], ax
  7038                                  
  7039                                  .no_dosdata_change:
  7040 000018DA 8905                    	mov word [di + soaSegSel], ax
  7041 000018DC EB1C                    	jmp @FFF
  7042                                  
  7043                                  @@:
  7044                                  		; Magic: Do not modify if called during modeswitching.
  7045 000018DE F606[0200]08            	testopt [internalflags], modeswitched
  7046 000018E3 7517                    	jnz .from_done_change		; cancel this -->
  7047                                  
  7048 000018E5 8B5D02                  	mov bx, word [di + soaSegment]
  7049 000018E8 B80200                  	mov ax, 0002h
  7050 000018EB CD31                    	int 31h
  7051 000018ED 7302                    	jnc @F
  7052 000018EF 31C0                    	xor ax, ax
  7053                                  @@:
  7054 000018F1 8905                    	mov word [di + soaSegSel], ax
  7055 000018F3 894504                  	mov word [di + soaSelector], ax
  7056 000018F6 83650200                	and word [di + soaSegment], 0
  7057                                  @@:
  7058                                  %if $ - .from_86m_now_pm.loop > 126
  7059                                  	loop .from_86m_now_pm.loop_j
  7060                                  	jmp .from_done_change
  7061                                  
  7062                                  .from_86m_now_pm.loop_j:
  7063                                  	jmp .from_86m_now_pm.loop
  7064                                  %else
  7065 000018FA E2C4                    	loop .from_86m_now_pm.loop
  7066                                  %endif
  7067                                  .from_done_change:
  7068                                  .from_no_change:
  7069                                  
  7070                                  
  7071                                  remember_mode:
  7072 000018FC 8026[0200]BF            	clropt [internalflags3], dif3_prior_pm
  7073 00001901 E8(0000)                	call ispm
  7074 00001904 7505                    	jnz .from_86m
  7075                                  .from_pm:
  7076 00001906 800E[0200]40            	setopt [internalflags3], dif3_prior_pm
  7077                                  .from_86m:
  7078 0000190B C3                      	retn
  7079                                  %endif
  7080                                  
  7081                                  
  7082                                  %if _MMXSUPP && _MMX_REDETECT && _PM
  7083                                  mmx_redetect:
  7084 0000190C C3                      _no386	retn
  7085                                  %ifn _ONLYNON386
  7086                                  subcpu 386
  7087 0000190D 6650                    	push eax
  7088 0000190F 6653                    	push ebx
  7089 00001911 6651                    	push ecx
  7090 00001913 6652                    	push edx
  7091                                  
  7092 00001915 C606[0000]00            	mov byte [has_mmx], 0	; if no 486 or no cpuid, reset
  7093                                  
  7094                                  ; Copied from init.asm, debugging messages
  7095                                  ;  and machine variable access removed.
  7096 0000191A 89E3                    	mov bx, sp		; save current stack pointer to align
  7097 0000191C 83E4FC                  	and sp, ~3		; align stack to avoid AC fault
  7098 0000191F 669C                    	pushfd			; push original EFLAGS
  7099 00001921 6658                    	pop eax			; get original EFLAGS
  7100 00001923 6689C1                  	mov ecx, eax		; save original EFLAGS in ECX (including IF)
  7101                                  
  7102 00001926 663500000400            	xor eax, 40000h		; flip AC bit in EFLAGS
  7103 0000192C 25FFFD                  	and ax, ~0200h		; clear IF
  7104 0000192F 6650                    	push eax		; put new EFLAGS value on stack
  7105 00001931 669D                    	popfd			; replace EFLAGS value; DI
  7106 00001933 669C                    	pushfd			; get new EFLAGS
  7107 00001935 6658                    	pop eax			; store new EFLAGS value in EAX
  7108 00001937 89C8                    	mov ax, cx		; ignore low bits (including IF)
  7109 00001939 6639C8                  	cmp eax, ecx
  7110 0000193C 7416                    	je .cpudone_stack_eax_equals_ecx	; if 80386 -->
  7111                                  
  7112                                  		; Intel486 DX CPU, Intel487 SX NDP, and Intel486 SX CPU check.
  7113                                  		; Checking for ability to set/clear ID flag (bit 21) in EFLAGS
  7114                                  		; which indicates the presence of a processor with the ability
  7115                                  		; to use the CPUID instruction.
  7116 0000193E 6689C8                  	mov eax, ecx		; get original EFLAGS
  7117 00001941 663500002000            	xor eax, 200000h	; flip ID bit in EFLAGS
  7118 00001947 25FFFD                  	and ax, ~0200h		; clear IF
  7119 0000194A 6650                    	push eax		; save new EFLAGS value on stack
  7120 0000194C 669D                    	popfd			; replace current EFLAGS value; DI
  7121 0000194E 669C                    	pushfd			; get new EFLAGS
  7122 00001950 6658                    	pop eax			; store new EFLAGS in EAX
  7123 00001952 89C8                    	mov ax, cx		; ignore low bits (including IF)
  7124                                  
  7125                                  .cpudone_stack_eax_equals_ecx:
  7126 00001954 6651                    	push ecx
  7127 00001956 669D                    	popfd			; restore AC,ID bits and IF in EFLAGS (86 Mode)
  7128 00001958 89DC                    	mov sp, bx		; restore sp
  7129                                  
  7130 0000195A 6639C8                  	cmp eax, ecx		; check if it's changed
  7131 0000195D 741E                    	je .cpudone		; if it's a 486 (can't toggle ID bit) -->
  7132                                  
  7133                                  		; Execute CPUID instruction.
  7134                                  subcpu 486		; NASM (at least 2.10rc1) handles cpuid itself as a
  7135                                  			;  586+ instruction, but we know better. So this
  7136                                  			;  part is declared for 486 compatibility, and only
  7137                                  			;  the cpuid instructions are emitted with 586
  7138                                  			;  compatibility to appease NASM.
  7139 0000195F 6631C0                  	xor eax, eax		; set up input for CPUID instruction
  7140                                  	  [cpu 586]
  7141 00001962 0FA2                    	 cpuid
  7142                                  	  __CPU__
  7143 00001964 6683F801                	cmp eax, byte 1
  7144 00001968 7213                    	jb .cpudone		; if 1 is not a valid input value for CPUID
  7145 0000196A 6631C0                  	xor eax, eax		; otherwise, run CPUID with eax = 1
  7146 0000196D 6640                    	inc eax
  7147                                  	  [cpu 586]
  7148 0000196F 0FA2                    	 cpuid
  7149                                  	  __CPU__
  7150 00001971 66F7C200008000          	test edx, 80_0000h
  7151 00001978 0F9506[0000]            	setnz byte [has_mmx]
  7152                                  .cpudone:
  7153 0000197D 665A                    	pop edx
  7154 0000197F 6659                    	pop ecx
  7155 00001981 665B                    	pop ebx
  7156 00001983 6658                    	pop eax
  7157 00001985 C3                      	retn
  7158                                  
  7159                                  subcpureset
  7160                                  subcpureset
  7161                                  %endif
  7162                                  %endif
  7163                                  
  7164                                  
  7165                                  %if _PM && _DEBUG
  7166                                  		; INP:	-
  7167                                  		; OUT:	es = ds
  7168                                  		; CHG:	eax, edx, bx, cx, bp, si, di
  7169                                  		; STT:	in PM
  7170                                  		;	do not call InDOS or other functions using seg/sels
  7171                                  pm_set_handlers:
  7172                                  	xor bp, bp		; = 0 if no 386
  7173                                  _386	inc bp
  7174                                  _386	inc bp			; = 2 if 386
  7175                                  
  7176                                  	 push ds
  7177                                  	 pop es
  7178                                  
  7179                                  	mov si, exctab		; hook several exceptions
  7180                                  %if _DEBUGUPDATESAVE
  7181                                  	mov di, excsave
  7182                                  %endif
  7183                                  _386	xor edx, edx		; clear edxh
  7184                                  	mov dx, exc_first
  7185                                  .loopexc:
  7186                                  	lodsb
  7187                                  	mov bl, al
  7188                                  
  7189                                  %if _DEBUGUPDATESAVE
  7190                                  	_386_o32	; push edx
  7191                                  	push dx			; preserve excXX pointer
  7192                                  	mov ax, 0202h
  7193                                  		; (edxh is zero)
  7194                                  	int 31h			; cx:(e)dx -> prior handler
  7195                                  	_386_o32	; xchg eax, edx
  7196                                  	xchg ax, dx
  7197                                  	_386_o32	; stosd
  7198                                  	stosw			; store offset (dword on 386+, else word)
  7199                                  	xchg ax, cx
  7200                                  	stosw			; store selector
  7201                                  	mov ax, 4
  7202                                  	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7203                                  	add di, ax		; -> next entry of excsave
  7204                                  	_386_o32	; pop edx
  7205                                  	pop dx
  7206                                  %endif
  7207                                  
  7208                                  	mov cx, word [cssel]	; -> our handler for this exception
  7209                                  	mov ax, 0203h
  7210                                  	int 31h			; set our handler
  7211                                   %ifn _LINK
  7212                                  	add dx, byte exc_second - exc_first
  7213                                   %else
  7214                                  	add dx, strict byte 0
  7215                                   wlcalc byte_ext_exc_second, equ $ - 1
  7216                                   wlcalc byte_minusext_exc_first, equ $ - 1
  7217                                   %endif
  7218                                  				; -> next handler
  7219                                  	cmp si, endexctab	; if another to go -->
  7220                                  	jb .loopexc
  7221                                  
  7222                                   %if _CATCHPMINT214C
  7223                                  	mov si, pminttab	; ds:si -> pminttab
  7224                                    %if _DEBUGUPDATESAVE
  7225                                  	mov di, pmintsave	; es:di -> pmintsave
  7226                                    %endif
  7227                                  .loopint:
  7228                                  	lodsb			; get interrupt number
  7229                                  	mov bl, al		; bl = interrupt number
  7230                                  
  7231                                    %if _DEBUGUPDATESAVE
  7232                                  _386	xor edx, edx		; clear edxh
  7233                                  	mov ax, 0204h
  7234                                  	int 31h			; cx:(e)dx -> prior handler
  7235                                  	_386_o32	; xchg eax, edx
  7236                                  	xchg ax, dx		; (e)ax = offset
  7237                                  	_386_o32	; stosd
  7238                                  	stosw			; store offset (dword on 386+, else word)
  7239                                  	xchg ax, cx
  7240                                  	stosw			; store selector
  7241                                  	mov ax, 4
  7242                                  	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7243                                  	add di, ax		; -> next entry of pmintsave
  7244                                    %endif
  7245                                  
  7246                                  	lodsw			; ax -> our handler
  7247                                  _386	xor edx, edx
  7248                                  	xchg ax, dx		; (e)dx -> our handler
  7249                                  	mov cx, word [cssel]	; cx:(e)dx -> our handler
  7250                                  	mov ax, 0205h
  7251                                  	int 31h
  7252                                  	cmp si, pminttab.end
  7253                                  	jb .loopint
  7254                                   %endif
  7255                                  
  7256                                  	jmp resetmode
  7257                                  %endif
  7258                                  
  7259                                  
  7260                                  %if _PM && (_CATCHPMINT214C || _DEBUG || _TSR || _DEVICE)
  7261                                  		; INP:	-
  7262                                  		; OUT:	-
  7263                                  		; CHG:	eax, edx, bx, cx, bp, si, di
  7264                                  		; STT:	in PM
  7265                                  		;	do not call InDOS or other functions using seg/sels
  7266                                  pm_reset_handlers:
  7267 00001986 31ED                    	xor bp, bp		; = 0 if no 386
  7268 00001988 45                      _386	inc bp
  7269 00001989 45                      _386	inc bp			; = 2 if 386
  7270                                  
  7271                                  
  7272                                   %if CATCHEXCAMOUNT
  7273                                  		; unhook exceptions
  7274 0000198A BF[0000]                	mov di, exctab
  7275 0000198D BE[0000]                	mov si, excsave
  7276                                  .loopexc:
  7277 00001990 8A1D                    	mov bl, [di]		; bl = exception number
  7278 00001992 47                      	inc di
  7279 00001993 66                      	_386_o32	; lodsd
  7280 00001994 AD                      	lodsw			; load offset (dword on 386+, else word)
  7281 00001995 66                      	_386_o32	; xchg eax, edx
  7282 00001996 92                      	xchg ax, dx
  7283 00001997 AD                      	lodsw			; load selector
  7284 00001998 91                      	xchg ax, cx		; cx:(e)dx -> prior handler
  7285 00001999 B80400                  	mov ax, 4
  7286 0000199C 29E8                    	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7287 0000199E 01C6                    	add si, ax		; -> next entry of excsave
  7288 000019A0 B80302                  	mov ax, 0203h
  7289 000019A3 CD31                    	int 31h			; set previous handler
  7290 000019A5 81FF[0000]              	cmp di, endexctab	; if another to go -->
  7291 000019A9 72E5                    	jb .loopexc
  7292                                   %endif
  7293                                  
  7294                                  
  7295                                   %if CATCHPMINTAMOUNT
  7296                                  		; unhook interrupts
  7297 000019AB BF[0000]                	mov di, pminttab	; ds:di -> pminttab
  7298 000019AE BE[0000]                	mov si, pmintsave	; ds:si -> pmintsave
  7299                                  .loopint:
  7300 000019B1 8A1D                    	mov bl, [di]		; bl = interrupt number
  7301 000019B3 83C703                  	add di, 3		; -> after this pminttab entry
  7302 000019B6 66                      	_386_o32	; lodsd
  7303 000019B7 AD                      	lodsw			; load offset (dword on 386+, else word)
  7304 000019B8 66                      	_386_o32	; xchg eax, edx
  7305 000019B9 92                      	xchg ax, dx
  7306 000019BA AD                      	lodsw			; load selector
  7307 000019BB 91                      	xchg ax, cx		; cx:(e)dx -> prior handler
  7308 000019BC B80400                  	mov ax, 4
  7309 000019BF 29E8                    	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7310 000019C1 01C6                    	add si, ax		; -> next entry of pmintsave
  7311 000019C3 B80502                  	mov ax, 0205h
  7312 000019C6 CD31                    	int 31h			; set previous handler
  7313 000019C8 81FF[0000]              	cmp di, pminttab.end	; if another to go -->
  7314 000019CC 72E3                    	jb .loopint
  7315                                   %endif
  7316                                  
  7317 000019CE E943F0                  	jmp resetmode
  7318                                  %endif
  7319                                  
  7320                                  
  7321                                  %if _DEBUG1
  7322                                  		; INP:	bx -> dword address, word counter
  7323                                  		;	dx:ax = linear address to check
  7324                                  		; OUT:	NC if to proceed as usual
  7325                                  		;	CY if address matched and counter indicates trigger
  7326                                  		;	 (ie, this should cause the caller to fail)
  7327                                  		;	If the address matched, the counter has been stepped.
  7328                                  		;	(The result of that step indicates whether to trigger.)
  7329                                  		; STT:	ds = ss = debugger data selector
  7330                                  handle_test_case:
  7331                                  	cmp word [bx], ax
  7332                                  	jne .proceed
  7333                                  	cmp word [bx + 2], dx
  7334                                  	jne .proceed
  7335                                  
  7336                                  	test word [bx + 4], 7FFFh	; is it already at a terminal state ?
  7337                                  	jz .no_decrement		; yes, do not further decrement -->
  7338                                  	dec word [bx + 4]		; decrement (towards 0 or 8000h)
  7339                                  	jz .trigger			; case for decrementing 1 to 0 -->
  7340                                  .no_decrement:
  7341                                  	cmp word [bx + 4], 8000h	; decrement resulted in 8000h
  7342                                  	je .trigger			;  or was already in that state? -->
  7343                                  .proceed:
  7344                                  	clc
  7345                                  	retn
  7346                                  
  7347                                  .trigger:
  7348                                  	stc
  7349                                  	retn
  7350                                  
  7351                                  
  7352                                  		; INP:	bx -> first test record (dword address, word counter)
  7353                                  		;	dx:ax = linear address to check
  7354                                  		;	cx = number of consecutive test records to check
  7355                                  		; OUT:	NC if to proceed as usual
  7356                                  		;	CY if address matched and counter indicates trigger
  7357                                  		;	 (ie, this should cause the caller to fail)
  7358                                  		; CHG:	bx, cx
  7359                                  		; STT:	ds = ss = debugger data selector
  7360                                  		;
  7361                                  		; Note that all test cases are tried and, if the address
  7362                                  		;  matches, their counters are stepped. In particular,
  7363                                  		;  a trigger no longer causes us to skip all further
  7364                                  		;  test cases that may have the same address.
  7365                                  		; If at least one of the matching test cases indicates a
  7366                                  		;  trigger condition after its stepping, the return is CY.
  7367                                  handle_test_case_multiple_16:
  7368                                  	mov cx, 16
  7369                                  handle_test_case_multiple:
  7370                                  	clc
  7371                                  	pushf				; initialise flags on stack with NC
  7372                                  	jcxz .end
  7373                                  .loop:
  7374                                  	call handle_test_case
  7375                                  	jnc .next
  7376                                  	popf				; (discard)
  7377                                  	stc
  7378                                  	pushf				; new flags on stack with CY
  7379                                  .next:
  7380                                  	add bx, 6
  7381                                  	loop .loop
  7382                                  .end:
  7383                                  	popf				; CF
  7384                                  	retn
  7385                                  %endif
  7386                                  
  7387                                  
  7388                                  %if !_LOADER
  7389                                  	usesection lDEBUG_DATA_ENTRY
  7389          ------------------       note: usesection lDEBUG_DATA_ENTRY
  7390 00000443 00                      	align 4, db 0
  7391 00000444 01000000                default_pp_count:	dd 1
  7392 00000448 01000000                default_tp_count:	dd 1
  7393 0000044C 01000000                default_tt_count:	dd 1
  7394                                  
  7395                                  
  7396                                  	usesection lDEBUG_CODE
  7396          ------------------       note: usesection lDEBUG_CODE
  7397                                  ;	PARSE_PT - Parse 'p' or 't' command. Also resets pagedcommand flag.
  7398                                  ;	Entry	AL	First character of command
  7399                                  ;		SI	Address of next character
  7400                                  ;		[internalflags2] & dif2_is_pp = set if P
  7401                                  ;		[internalflags] & tt_p = set if TP
  7402                                  ;		both clear if T
  7403                                  ;	Exit	BX:CX	Number of times to repeat
  7404                                  ;	Uses	AH,BX,CX,DX.
  7405                                  
  7406                                  parse_pt:
  7407 000019D1 E8(0000)                	call guard_re
  7408 000019D4 C706[0000][0000]        	mov word [gg_deferred_message], msg.empty_message
  7409 000019DA 8326[0000]00            	and word [bb_deferred_message_in_lineout_behind], 0
  7410 000019DF 8026[0000]F7            	clropt [internalflags2], dif2_gg_is_gg
  7411 000019E4 8026[0300]2B            	clropt [internalflags], 		tt_while | tt_silent_mode | tt_no_bb | tt_no_bb_first
  7413 000019E9 8326[0000]00            	and word [tt_silent_mode_number], 0
  7414                                  
  7415                                  		; TP.NB, T.NB, P.NB: trace/proceed without bb breakpoints
  7416                                  		;
  7417                                  		; Note that when such a command is repeated through lastcmd,
  7418                                  		; it gets an empty line, thus tt_no_bb remains clear, and
  7419                                  		; the corresponding command without .NB is run.
  7420 000019EE 3C2E                    	cmp al, '.'
  7421 000019F0 7520                    	jne .no_dot
  7422                                  
  7423 000019F2 AD                      	lodsw
  7424 000019F3 25DFDF                  	and ax, TOUPPER_W
  7425 000019F6 3D4E42                  	cmp ax, "NB"
  7426 000019F9 7411                    	je .dot_nb
  7427                                  		; TP.SB, T.SB, P.SB: trace/proceed without bb for first step
  7428 000019FB 3D5342                  	cmp ax, "SB"
  7429 000019FE 7405                    	je .dot_sb
  7430 00001A00 4E                      	dec si
  7431 00001A01 4E                      	dec si
  7432 00001A02 E9(0000)                	jmp error
  7433                                  
  7434                                  .dot_sb:
  7435 00001A05 800E[0300]80            	setopt [internalflags], tt_no_bb_first
  7436 00001A0A EB05                    	jmp .dot_common
  7437                                  
  7438                                  .dot_nb:
  7439 00001A0C 800E[0300]40            	setopt [internalflags], tt_no_bb
  7440                                  .dot_common:
  7441 00001A11 AC                      	lodsb
  7442                                  .no_dot:
  7443 00001A12 E85B01                  	call parseql		; process =addr
  7444 00001A15 E8(0000)                	call skipcomm0		; skip any white space
  7445                                  
  7446 00001A18 BA0400                  	mov dx, opt3_pp_no_paging
  7447 00001A1B 8B1E[4604]              	mov bx, word [default_pp_count + 2]
  7448 00001A1F 8B0E[4404]              	mov cx, word [default_pp_count]
  7449 00001A23 F606[0100]10            	testopt [internalflags2], dif2_is_pp
  7450 00001A28 751D                    	jnz @F
  7451 00001A2A BA0200                  	mov dx, opt3_tp_no_paging
  7452 00001A2D 8B1E[4A04]              	mov bx, word [default_tp_count + 2]
  7453 00001A31 8B0E[4804]              	mov cx, word [default_tp_count]
  7454 00001A35 F606[0300]08            	testopt [internalflags], tt_p
  7455 00001A3A 750B                    	jnz @F
  7456 00001A3C BA0100                  	mov dx, opt3_tt_no_paging
  7457 00001A3F 8B1E[4E04]              	mov bx, word [default_tt_count + 2]
  7458 00001A43 8B0E[4C04]              	mov cx, word [default_tt_count]
  7459                                  @@:				; bx:cx = default count
  7460                                  
  7461 00001A47 8516[0000]              	test word [options3], dx
  7462 00001A4B 7405                    	jz @F
  7463 00001A4D 8026[0000]F7            	clropt [internalflags], pagedcommand
  7464                                  @@:
  7465                                  
  7466                                  		; Initialise auxbuff pointers.
  7467 00001A52 E80301                  	call tpg_initialise_empty_auxbuff
  7468                                  
  7469 00001A55 E8(0000)                	call iseol?
  7470                                  %if _LINK_COMPAT
  7471 00001A58 7503                    	jne @F
  7472 00001A5A E98400                  	jmp strict near .ppt1	; if no count given --> (uses bx:cx = default)
  7473                                  @@:
  7474                                  %else
  7475                                  	je .ppt1		; if no count given --> (uses bx:cx = default)
  7476                                  %endif
  7477 00001A5D E8(0000)[0000]          	nearcall getdword	; bx:dx = given count
  7478                                  
  7479 00001A62 53                      	push bx
  7480 00001A63 52                      	push dx			; push count
  7481 00001A64 E8(0000)                	call skipcomm0
  7482 00001A67 E8(0000)                	call iseol?
  7483 00001A6A 7473                    	je .no_while
  7484 00001A6C 4E                      	dec si
  7485 00001A6D BA[0000]                	mov dx, msg.while
  7486 00001A70 E8(0000)                	call isstring?
  7487 00001A73 7405                    	je .found_while
  7488                                  
  7489 00001A75 E8B400                  	call .handle_silent	; (error if no SILENT keyword)
  7490                                  
  7491 00001A78 EB65                    	jmp .no_while
  7492                                  
  7493                                  
  7494                                  .found_while:
  7495 00001A7A E8(0000)                	call skipcomma
  7496 00001A7D 4E                      	dec si
  7497 00001A7E 89F1                    	mov cx, si
  7498 00001A80 AC                      	lodsb
  7499 00001A81 E8(0000)[0000]          	nearcall getexpression
  7500 00001A86 E8(0000)[0000]          	nearcall toboolean
  7501 00001A8B E8(0000)                	call skipcomm0
  7502 00001A8E 52                      	push dx
  7503 00001A8F 56                      	push si
  7504 00001A90 E8(0000)                	call iseol?		; expect end of line here
  7505 00001A93 7404                    	je .no_while_silent
  7506                                  
  7507 00001A95 4E                      	dec si
  7508 00001A96 E89300                  	call .handle_silent
  7509                                  
  7510                                  .no_while_silent:
  7511 00001A99 5E                      	pop si
  7512 00001A9A 5A                      	pop dx
  7513 00001A9B 85D2                    	test dx, dx		; condition true now ?
  7514 00001A9D 750F                    	jnz @F
  7515                                  
  7516 00001A9F BA[0000]                	mov dx, msg.while_not_true
  7517 00001AA2 E8(0000)                	call putsz
  7518 00001AA5 B83601                  	mov ax, 0136h
  7519 00001AA8 E8(0000)                	call setrc
  7520 00001AAB E9(0000)                	jmp cmd3
  7521                                  
  7522                                  @@:
  7523                                  		; (si + 1) -> line terminator (13, ';', 0) or next keyword
  7524                                  @@:
  7525 00001AAE 4E                      	dec si			; -> terminator, or blank
  7526 00001AAF 807CFF20                	cmp byte [si - 1], 32	; another blank at end ?
  7527 00001AB3 74F9                    	je @B			; yes -->
  7528 00001AB5 807CFF09                	cmp byte [si - 1], 9
  7529 00001AB9 74F3                    	je @B			; yes -->
  7530 00001ABB 807CFF2C                	cmp byte [si - 1], ','	; comma at end ?
  7531 00001ABF 74ED                    	je @B			; yes -->
  7532 00001AC1 89F0                    	mov ax, si
  7533 00001AC3 29C8                    	sub ax, cx		; ax = length of expression
  7534 00001AC5 3D[FFFF]                	cmp ax, while_buffer.length - 1
  7535 00001AC8 7603E9(0000)            	ja error
  7536 00001ACD 57                      	push di
  7537 00001ACE BF[0000]                	mov di, while_buffer
  7538 00001AD1 89CE                    	mov si, cx		; -> expression start
  7539 00001AD3 91                      	xchg cx, ax		; cx = length of expression
  7540 00001AD4 F3A4                    	rep movsb		; store expression
  7541 00001AD6 B000                    	mov al, 0
  7542 00001AD8 AA                      	stosb			; terminate string
  7543 00001AD9 5F                      	pop di
  7544                                  
  7545 00001ADA 800E[0300]04            	setopt [internalflags], tt_while
  7546                                  .no_while:
  7547 00001ADF 59                      	pop cx
  7548 00001AE0 5B                      	pop bx			; bx:cx = given count
  7549                                  
  7550                                  .ppt1:
  7551 00001AE1 85DB                    	test bx, bx
  7552 00001AE3 7507                    	jnz @F
  7553 00001AE5 85C9                    	test cx, cx
  7554 00001AE7 7503E9(0000)            	jz error		; must be at least 1, else error -->
  7555                                  @@:
  7556 00001AEC 53                      	push bx
  7557 00001AED 51                      	push cx
  7558                                  
  7559 00001AEE 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  7562                                  
  7563 00001AF3 F606[0200]04            	testopt [options], tp_do_not_skip_bp
  7564 00001AF8 752C                    	jnz .do_not_skip_cseip
  7565 00001AFA 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
  7566                                  
  7567 00001AFF 803E[0000]00            	cmp byte [eqflag], 0
  7568 00001B04 7508                    	jne .cseip_take_eql
  7569                                  
  7570 00001B06 66                      	_386_PM_o32		; xor ecx, ecx
  7571 00001B07 31C9                    	xor cx, cx
  7572 00001B09 E8AEED                  	call get_cseip_ecx_linear
  7573 00001B0C EB0C                    	jmp .got_cseip
  7574                                  
  7575                                  .cseip_take_eql:
  7576 00001B0E 8B1E[0400]              	mov bx, word [eqladdr + 4]
  7577 00001B12 66                      	_386_PM_o32		; mov edx, dword [eqladdr]
  7578 00001B13 8B16[0000]              	mov dx, word [eqladdr]
  7579 00001B17 E8ACED                  	call getlinear_d_b
  7580                                  .got_cseip:
  7581 00001B1A 7303E9(0000)            	jc error
  7582 00001B1F A3[0000]                	mov word [gg_first_cseip_linear], ax
  7583 00001B22 8916[0200]              	mov word [gg_first_cseip_linear + 2], dx
  7584                                  .do_not_skip_cseip:
  7585                                  
  7586 00001B26 59                      	pop cx
  7587 00001B27 5B                      	pop bx
  7588                                  
  7589 00001B28 E86800                  	call seteq		; make the = operand take effect
  7590 00001B2B C3                      	retn
  7591                                  
  7592                                  
  7593                                  .handle_silent:
  7594 00001B2C BA[0000]                	mov dx, msg.silent
  7595 00001B2F E8(0000)                	call isstring?
  7596 00001B32 7403E9(0000)            	jne error
  7597 00001B37 E8(0000)                	call skipcomma
  7598 00001B3A 4E                      	dec si
  7599 00001B3B E8(0000)                	call skipequals
  7600 00001B3E E8(0000)                	call iseol?
  7601 00001B41 740C                    	je .no_silent_mode_number
  7602                                  
  7603 00001B43 E8(0000)[0000]          	nearcall getword
  7604 00001B48 8916[0000]              	mov word [tt_silent_mode_number], dx
  7605 00001B4C E8(0000)                	call chkeol
  7606                                  
  7607                                  .no_silent_mode_number:
  7608 00001B4F E8(0000)                	call guard_auxbuff.1_or_2
  7609 00001B52 800E[0300]10            	setopt [internalflags], tt_silent_mode
  7610 00001B57 C3                      	retn
  7611                                  
  7612                                  
  7613                                  		; INP:	(_PM) word [auxbuff_switchbuffer_size]
  7614                                  		;	word [auxbuff_behind_last_silent]
  7615                                  		;	[options6] & opt6_rh_mode
  7616                                  		; OUT:	word [auxbuff_behind_last_silent]
  7617                                  		;	word [auxbuff_start_silent]
  7618                                  		; CHG:	dx
  7619                                  tpg_initialise_empty_auxbuff:
  7620                                  %if _RH
  7621 00001B58 8B16[0000]              	mov dx, word [auxbuff_behind_last_silent]
  7622 00001B5C F606[0200]10            	testopt [options6], opt6_rh_mode
  7623 00001B61 7508                    	jnz .last
  7624                                  %endif
  7625                                  .reset:
  7626                                  %if _PM
  7627 00001B63 8B16[0000]              	mov dx, word [auxbuff_switchbuffer_size]
  7628                                  %else
  7629                                  	xor dx, dx
  7630                                  %endif
  7631 00001B67 8916[0000]              	mov word [auxbuff_behind_last_silent], dx
  7632                                  .last:
  7633                                  %if _RH
  7634 00001B6B 8916[0000]              	mov word [auxbuff_start_silent], dx
  7635                                  %endif
  7636 00001B6F C3                      	retn
  7637                                  
  7638                                  
  7639                                  ;	PARSEQL - Parse `=' operand for `g', 'p' and `t' commands.
  7640                                  ;	Entry	AL	First character of command
  7641                                  ;			SI	Address of next character
  7642                                  ;	Exit	AL	First character beyond range
  7643                                  ;			SI	Address of the character after that
  7644                                  ;			eqflag	Nonzero if an `=' operand was present
  7645                                  ;			eqladdr	Address, if one was given
  7646                                  ;	Uses AH,BX,CX,DX.
  7647                                  
  7648                                  parseql:
  7649 00001B70 C606[0000]00            	mov byte [eqflag], 0	; mark '=' as absent
  7650 00001B75 3C3D                    	cmp al, '='
  7651 00001B77 7519                    	jne peq1		; if no '=' operand
  7652 00001B79 E8(0000)                	call skipwhite
  7653 00001B7C 8B1E[0000]              	mov bx, word [reg_cs]	; default segment
  7654 00001B80 E8(0000)[0000]          	nearcall getaddrX	; get the address into bx:(e)dx
  7655 00001B85 66                      	_386_PM_o32	; mov dword [eqladdr], edx
  7656 00001B86 8916[0000]              	mov word [eqladdr+0], dx
  7657 00001B8A 891E[0400]              	mov word [eqladdr+4], bx
  7658 00001B8E FE06[0000]              	inc byte [eqflag]
  7659                                  peq1:
  7660 00001B92 C3                      	retn
  7661                                  
  7662                                  
  7663                                  		; SETEQ - Copy the = arguments to their place, if appropriate.
  7664                                  		; (This is not done immediately, because the command may have
  7665                                  		; a syntax error.)
  7666                                  		; Uses AX.
  7667                                  seteq:
  7668 00001B93 803E[0000]00            	cmp byte [eqflag], 0
  7669 00001B98 7417                    	je .return		; if no `=' operand
  7670 00001B9A A1[0000]                	mov ax, word [eqladdr+0]
  7671 00001B9D A3[0000]                	mov word [reg_eip], ax
  7672                                  %if _PM
  7673 00001BA0 A1[0200]                	mov ax, word [eqladdr+2]
  7674 00001BA3 A3[0200]                	mov word [reg_eip+2], ax
  7675                                  %endif
  7676 00001BA6 A1[0400]                	mov ax, word [eqladdr+4]
  7677 00001BA9 A3[0000]                	mov word [reg_cs], ax
  7678 00001BAC C606[0000]00            	mov byte [eqflag], 0	; clear the flag
  7679                                  .return:
  7680 00001BB1 C3                      	retn
  7681                                  %endif	; !_LOADER
  7682                                  
  7683                                  usesection lDEBUG_CODE
  7683          ------------------       note: usesection lDEBUG_CODE
  7684                                  
  7685                                  ..@run_access_end:
