     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
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739 00000006 ????                <1> saSegment:	resw 1
   740 00000008 ????                <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753 00000004 ????                <1> so16aSegment:	resw 1
   754 00000006 ????                <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777 00000002 ????                <1> soaSegment:	resw 1
   778 00000004 ????                <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    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 E8961C                  	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 E85308                  	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 E85108                  	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 E83807                  	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 E89604                  	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 E8DB06                  	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 E8AD07                  	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 E8FB1A                  	call tpg_initialise_empty_auxbuff
   554                                  %if _BREAKPOINTS
   555 000001D5 E84104                  	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 E8AC05                  	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 E89F04                  	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 E8E804                  	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 E80313                  	call display_breakpoint_failure
   637 0000021E 59                      	pop cx
   638 0000021F E85F06                  	call gg_handlefailedrestore
   639                                  %if _BREAKPOINTS
   640 00000222 E82A06                  	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 E84F04                  	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 E84304                  	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 E88404                  	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 E81A06                  	call gg_handlefailedrestore
   712                                  %endif
   713                                  %if _BREAKPOINTS
   714 00000267 E8E505                  	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 E87104                  	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 E80F04                  	call gg_restorepoints
   748 0000028B 51                      	push cx
   749                                  %endif
   750 0000028C B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   751 0000028F E85804                  	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 E87E07                  	call resetmode
   772                                  %endif
   773 000002A0 E86A1A                  	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 E8CE13                  	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 E84C0F                  _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 E80213                  	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 E83D0D                  	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 E88403                  	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 E8CD03                  	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 E8F906                  	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 E8E811                  	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 E85802                  	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 E8BE13                  	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 E84002                  	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 E8BB06                  	call resetmode
   932                                  %endif
   933 00000363 E84900                  	call put_deferred_message_silent
   934 00000366 E9820C                  	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 E83509                  	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 E8A106                  	call resetmode
   958                                  %endif
   959 0000037D E82F00                  	call put_deferred_message_silent
   960                                  				; (put bb message after gg_bb_check_hit call)
   961 00000380 E98310                  	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 E80003                  	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 E84903                  	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 E87C06                  	call resetmode
   991                                  %endif
   992 000003A2 E80A00                  	call put_deferred_message_silent
   993                                  
   994                                   %if _NUM_G_BP
   995 000003A5 E8D904                  	call gg_handlefailedrestore
   996                                  				; handle gg point restore failures
   997                                   %endif
   998                                   %if _BREAKPOINTS
   999 000003A8 E8A404                  	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 E88F0A                  	call putsz_silent
  1029 000003B9 BA[680E]                	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 E8A205                  	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 7403E95D01              	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 E8A904                  	call get_cseip_ecx_linear
  1137                                  				; get linear of this cs:(e)ip
  1138                                  .check:
  1139 00000415 7303E94D01              	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 7503E92101              	jz .next
  1156 00000434 84A7[0000]              	test byte [b_bplist.disabled_mask+bx], ah
  1157                                  				; (NC)
  1158 00000438 7403E91801              	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 E84701                  	call gg_bb_lods_bp_linear
  1181                                  
  1182 00000452 E89803                  	call gg_bb_check_is_first
  1183 00000455 7203E9FB00              	jnc .next
  1184                                  
  1185 0000045A 39C8                    	cmp ax, cx
  1186 0000045C 7403E9F400              	jne .next
  1187 00000461 39DA                    	cmp dx, bx
  1188 00000463 7403E9ED00              	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 7426                    	jz @F			; no -->
  1215                                  %if _PM
  1216 0000047A E8A105                  	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)EB02[0000]      	nearcall getexpression	; parse stored expression
  1222 0000048D E8(0000)                	call chkeol
  1223 00000490 E8(0000)EB02[0000]      	nearcall toboolean	; get boolean
  1224 00000497 85D2                    	test dx, dx		; true ?
  1225 00000499 7503E9B700              	jz .next		; no, skip -->
  1226 0000049E 58                      	 pop ax
  1227 0000049F 50                      	 push ax
  1228                                  @@:
  1229                                  
  1230 000004A0 8D9D[0000]              	lea bx, [b_bplist.counter + di]
  1231                                  				; word [bx] = this matched point's counter
  1232                                  
  1233 000004A4 F646FE03                	test byte [bp + ?flags], ?flag_trigger | ?flag_pass
  1234 000004A8 7413                    	jz @F			; none set yet ? -->
  1235 000004AA E8C100                  	call step_pass_counter	; step counter even if already matched
  1236 000004AD 7203E9A300              	jnc .next		; (either is already set, so additional
  1237                                  				;  setting of ?flag_pass is skipped)
  1238 000004B2 F646FE01                	test byte [bp + ?flags], ?flag_trigger
  1239 000004B6 7403E99A00              	jnz .next		; (trigger is already set, so skip triggering)
  1240 000004BB EB05                    	jmp .setup_trigger	; triggered (after previous pass match)
  1241                                  
  1242                                  @@:
  1243 000004BD E8AE00                  	call step_pass_counter	; step counter of matched point, no flag yet
  1244 000004C0 7340                    	jnc .check_pass		; not triggered, check for pass match -->
  1245                                  
  1246                                  .setup_trigger:
  1247                                  		; Trigger! (And the first detected triggering point.)
  1248 000004C2 804EFE01                	or byte [bp + ?flags], ?flag_trigger
  1249                                  
  1250 000004C6 51                      	push cx
  1251 000004C7 BF[0000]                	mov di, line_out
  1252 000004CA 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 000004CD 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 000004D0 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 000004D2 E8(0000)                	call hexbyte		; store index of this point
  1277                                  
  1278                                  		; Get counter of this breakpoint.
  1279 000004D5 8B07                    	mov ax, word [bx]
  1280                                  
  1281                                  		; Is it equal to default ?
  1282 000004D7 3D0080                  	cmp ax, 8000h
  1283 000004DA 7409                    	je @F			; yes, skip -->
  1284                                  
  1285 000004DC BE[0000]                	mov si, msg.bb_hit.2.counter
  1286 000004DF E8AF00                  	call copy_single_counted_string
  1287                                  		; Now si -> msg.bb_hit.3.counter.no_id
  1288                                  
  1289                                  		; Store counter in message.
  1290 000004E2 E8(0000)                	call hexword
  1291                                  
  1292                                  @@:
  1293 000004E5 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  1294 000004EA 7407                    	jz @F
  1295 000004EC F606[0200]08            	testopt [options], gg_bb_hit_no_repeat
  1296 000004F1 EB05                    	jmp @FF
  1297                                  @@:
  1298 000004F3 F606[0200]10            	testopt [options], tp_bb_hit_no_repeat
  1299                                  @@:
  1300 000004F8 7406                    	jz @F
  1301 000004FA C706[0000][0000]        	mov word [lastcmd], dmycmd
  1302                                  @@:
  1303 00000500 EB1D                    	jmp .trigger_common
  1304                                  
  1305                                  
  1306                                  .check_pass:
  1307 00000502 7451                    	jz .next		; no pass match ? -->
  1308                                  
  1309 00000504 804EFE02                	or byte [bp + ?flags], ?flag_pass
  1310                                  
  1311 00000508 51                      	push cx
  1312 00000509 BF[0000]                	mov di, line_out
  1313 0000050C BE[0000]                	mov si, msg.bb_pass.1
  1314 0000050F E87F00                  	call copy_single_counted_string
  1315                                  		; Now si -> msg.bb_pass.2
  1316                                  
  1317 00000512 89C2                    	mov dx, ax
  1318                                  		; Store breakpoint index in message.
  1319 00000514 E8(0000)                	call hexbyte		; store index of this point
  1320                                  
  1321 00000517 E87700                  	call copy_single_counted_string
  1322                                  		; Now si -> msg.bb_pass.3.no_id
  1323                                  
  1324                                  		; Get counter of this breakpoint.
  1325 0000051A 8B07                    	mov ax, word [bx]
  1326                                  		; Store counter in message.
  1327 0000051C E8(0000)                	call hexword
  1328                                  
  1329                                  .trigger_common:
  1330 0000051F 53                      	push bx
  1331                                  %if _SYMBOLIC
  1332                                  	cmp dx, _NUM_B_BP	; symbol breakpoint ?
  1333                                  	jae @F			; yes, no ID -->
  1334                                  %endif
  1335 00000520 BBFFFF                  	mov bx, -1
  1336 00000523 E8(0000)                	call get_set_id_offset_length
  1337 00000526 F6C7FC                  	test bh, 63 << 2	; length nonzero ?
  1338 00000529 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 0000052B BE[0000]                	mov si, msg.bb_hitpass_id.short
  1344 0000052E 80FF74                  	cmp bh, 29 << 2		; long ?
  1345 00000531 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 00000533 BE[0000]                	mov si, msg.bb_hitpass_id.long
  1350                                  .trigger_short_id:
  1351                                  
  1352 00000536 E85800                  	call copy_single_counted_string
  1353 00000539 88F9                    	mov cl, bh
  1354 0000053B D0E9                    	shr cl, 1
  1355 0000053D D0E9                    	shr cl, 1		; cx = length
  1356 0000053F 81E3FF03                	and bx, 1023		; bx = offset
  1357 00000543 8DB7[0000]              	lea si, [b_bplist.idbuffer + bx]
  1358 00000547 F3A4                    	rep movsb
  1359                                  
  1360 00000549 BE[0000]                	mov si, msg.bb_hitpass_id.after
  1361                                  
  1362                                  @@:
  1363 0000054C 5B                      	pop bx
  1364 0000054D E84100                  	call copy_single_counted_string
  1365                                  
  1366 00000550 893E[0000]              	mov word [bb_deferred_message_in_lineout_behind], di
  1367 00000554 59                      	pop cx
  1368                                  
  1369                                  .next:
  1370 00000555 58                      	pop ax
  1371 00000556 5B                      	pop bx
  1372                                  
  1373 00000557 40                      	inc ax
  1374 00000558 83F810                  	cmp ax, _NUM_B_BP + _NUM_SYM_BP
  1375 0000055B 7303E9C6FE              	jb .loop
  1376                                  
  1377 00000560 8B46FE                  	mov ax, word [bp + ?flags]
  1378 00000563 A807                    	test al, ?flag_pass | ?flag_trigger | ?flag_match
  1379 00000565 7503                    	jnz .return		; (NC)
  1380                                  
  1381                                  .gg9:
  1382 00000567 31C0                    	xor ax, ax
  1383 00000569 F9                      	stc
  1384                                  .return:
  1385 0000056A 89EC5D                  	lleave
  1386 0000056D 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 0000056E F707FF3F                	test word [bx], 3FFFh		; is it already at a terminal state ?
  1396 00000572 740A                    	jz .no_decrement		; yes, do not further decrement -->
  1397 00000574 FF0F                    	dec word [bx]			; decrement (to 0/4000h/8000h/C000h)
  1398 00000576 7417                    	jz .trigger			; case for decrementing 1 to 0 -->
  1399 00000578 813F0040                	cmp word [bx], 4000h
  1400 0000057C 7411                    	je .trigger			; case for decrementing 4001h to 4000h
  1401                                  .no_decrement:
  1402 0000057E 813F0080                	cmp word [bx], 8000h		; decrement resulted in 8000h
  1403 00000582 740B                    	je .trigger			;  or was already in that state? -->
  1404 00000584 813F00C0                	cmp word [bx], 0_C000h
  1405 00000588 7405                    	je .trigger			; or C000h -->
  1406                                  .proceed:
  1407 0000058A F6470140                	test byte [bx + 1], 40h		; (NC) ZR if no pass message
  1408 0000058E C3                      	retn
  1409                                  
  1410                                  .trigger:
  1411 0000058F F9                      	stc
  1412 00000590 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 00000591 91                      	xchg ax, cx
  1428 00000592 31C0                    	xor ax, ax
  1429 00000594 AC                      	lodsb
  1430 00000595 91                      	xchg ax, cx
  1431 00000596 F3A4                    	rep movsb
  1432 00000598 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 00000599 AD                      	lodsw
  1442 0000059A 92                      	xchg ax, dx
  1443                                  %if _PM
  1444 0000059B AD                      	lodsw
  1445                                  %else
  1446                                  	xor ax, ax
  1447                                  	lodsb
  1448                                  %endif
  1449 0000059C 92                      	xchg ax, dx
  1450 0000059D 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 0000059E E84BFE                  	call bb_check_hit
  1476 000005A1 720D                    	jc .gg_check_hit
  1477                                  
  1478 000005A3 A801                    	test al, 1		; actual bb hit ?
  1479 000005A5 7507                    	jnz .ret_NC		; yes, return as hit
  1480                                  
  1481 000005A7 50                      	push ax			; bb is pass match or any other match,
  1482 000005A8 E80500                  	call gg_check_hit	;  is gg a match ?
  1483 000005AB 58                      	pop ax
  1484 000005AC 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 000005AE F8                      	clc
  1491 000005AF 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 000005B0 813E[0000][0000]        	cmp word [run_int], int3msg
  1515 000005B6 752D                    	jne .gg9		; if not interrupt 03h -->
  1516                                  
  1517                                  			; Get previous cs:eip (where breakpoint was executed if any at all).
  1518 000005B8 E8E403                  	call get_cseip_of_possible_breakpoint
  1519                                  				; dx:ax = linear address of previous cs:eip
  1520 000005BB 7228                    	jc .gg9
  1521 000005BD BE[0000]                	mov si, g_bplist.bp
  1522 000005C0 31C9                    	xor cx, cx
  1523 000005C2 8A4CFF                  	mov cl, byte [si-1]	; number of saved breakpoints
  1524 000005C5 E31E                    	jcxz .gg9		; none, so always unexpected -->
  1525                                  
  1526 000005C7 89C7                    	mov di, ax
  1527 000005C9 89D3                    	mov bx, dx		; bx:di = linear address of previous cs:(e)ip
  1528                                  
  1529                                  .loop_gg6:
  1530 000005CB E8CBFF                  	call gg_bb_lods_bp_linear
  1531                                  
  1532 000005CE E81C02                  	call gg_bb_check_is_first
  1533 000005D1 730D                    	jnc .next
  1534                                  
  1535 000005D3 39DA                    	cmp dx, bx
  1536 000005D5 7509                    	jne .next
  1537 000005D7 39F8                    	cmp ax, di
  1538 000005D9 7505                    	jne .next
  1539                                  
  1540                                  .hit:
  1541 000005DB B80700                  	mov ax, 7
  1542 000005DE F8                      	clc
  1543 000005DF 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 000005E0 83C605                  	add si, 5		; skip dword offset and byte content
  1553                                  %endif
  1554                                  				; BPSIZE implied
  1555 000005E3 E2E6                    	loop .loop_gg6		; try next if there's any
  1556                                  
  1557                                  .gg9:
  1558 000005E5 31C0                    	xor ax, ax
  1559 000005E7 F9                      	stc
  1560 000005E8 C3                      	retn
  1561                                  %endif
  1562                                  
  1563                                  
  1564                                  %if _DELAY_BEFORE_BP
  1565                                  delay_before_bp:
  1566 000005E9 F606[0300]04            	testopt [options3], opt3_delay_before_bp
  1567 000005EE 7428                    	jz .ret
  1568 000005F0 F606[0200]80            	testopt [internalflags3], dif3_delayed
  1569 000005F5 7521                    	jnz .ret
  1570 000005F7 800E[0200]80            	setopt [internalflags3], dif3_delayed
  1571 000005FC 06                      	push es
  1572 000005FD 57                      	push di
  1573 000005FE 50                      	push ax
  1574 000005FF BF4000                  	mov di, 40h		; dual mode segment/selector
  1575 00000602 8EC7                    	mov es, di
  1576 00000604 268B3E6C00              	mov di, word [es:6Ch]
  1577                                  @@:
  1578 00000609 263B3E6C00              	cmp di, word [es:6Ch]
  1579 0000060E 7505                    	jne @F
  1580 00000610 E8(0000)                	call idle
  1581 00000613 EBF4                    	jmp @B
  1582                                  @@:
  1583 00000615 58                      	pop ax
  1584 00000616 5F                      	pop di
  1585 00000617 07                      	pop es
  1586                                  .ret:
  1587 00000618 C3                      	retn
  1588                                  %endif
  1589                                  
  1590                                  
  1591                                  %if _BREAKPOINTS
  1592                                  bb_writepoints_init_reset:
  1593 00000619 BF[0000]                	mov di, b_bplist.bp
  1594 0000061C B0CC                    	mov al, 0CCh
  1595 0000061E B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  1596                                  .loop:
  1597 00000621 83C708                  	add di, BPSIZE - 1
  1598 00000624 AA                      	stosb
  1599 00000625 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 00000627 E8D500                  	call bb_writepoints
  1707 0000062A 735B                    	jnc .retn
  1708                                  
  1709 0000062C 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1710                                  				; reserve space for bb error info
  1711 0000062F 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 00000631 50                      	push ax
  1716 00000632 51                      	push cx
  1717 00000633 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 00000636 E87F0E                  	call proceed_writepoint_restore
  1724                                  		; This call might return modeswitched.
  1725 00000639 BB0000                  	mov bx, 0		; (preserve CF)
  1726 0000063C 7305                    	jnc @F
  1727 0000063E 80CC80                  	or ah, 80h		; mark error during restoration
  1728 00000641 89C3                    	mov bx, ax		; bx & 80h set: error restoring pp
  1729                                  @@:
  1730                                  
  1731 00000643 59                      	pop cx
  1732 00000644 58                      	pop ax			; error info + index of failed point
  1733                                  
  1734 00000645 89CE                    	mov si, cx
  1735 00000647 01F6                    	add si, si
  1736 00000649 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 0000064B 01F6                    	add si, si		; * 8
  1745 0000064D 01CE                    	add si, cx		; * 9
  1746                                  %else
  1747                                   %error Unexpected breakpoint size
  1748                                  %endif
  1749 0000064F 81C6[0000]              	add si, b_bplist.bp	; -> point
  1750                                  
  1751 00000653 53                      	push bx
  1752                                  
  1753 00000654 E858FD                  	call put_deferred_message_silent
  1754                                  				; CHG: dx
  1755                                  
  1756 00000657 83F9FF                  	cmp cx, -1
  1757 0000065A 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 0000065C FF7402                  	 push word [si + 2]
  1763 0000065F FF34                    	 push word [si]		; stack: linear address
  1764 00000661 BB0040                  	mov bx, 4000h		; bh = 40h (bb),
  1765                                  				;  bl = what we tried to restore (n/a)
  1766 00000664 E8BA0E                  	call display_breakpoint_failure
  1767                                  		; This function calls resetmode.
  1768                                  
  1769                                  @@:
  1770 00000667 E8E501                  	call bb_handlefailedrestore
  1771                                  		; This function calls resetmode.
  1772                                  
  1773 0000066A 58                      	pop ax
  1774 0000066B F6C480                  	test ah, 80h		; pp failed to restore ?
  1775 0000066E 7411                    	jz @F
  1776                                  
  1777 00000670 FF36[0200]              	 push word [tpg_proceed_bp + 2]
  1778 00000674 FF36[0000]              	 push word [tpg_proceed_bp]
  1779 00000678 8A1E[0800]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
  1780 0000067C B700                    	mov bh, 0		; proceed breakpoint
  1781 0000067E E8A00E                  	call display_breakpoint_failure
  1782                                  @@:
  1783 00000681 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1784                                  				; discard bb error info
  1785 00000684 E9(0000)                	jmp cmd3
  1786                                  
  1787                                  .retn:
  1788 00000687 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 00000688 16                      	push ss
  1800 00000689 07                      	pop es
  1801 0000068A 89EF                    	mov di, bp		; es:di -> behind error info
  1802 0000068C 51                      	push cx
  1803 0000068D 4F                      	dec di
  1804 0000068E 4F                      	dec di
  1805 0000068F 31C0                    	xor ax, ax
  1806 00000691 FD                      	std			; _AMD_ERRATUM_109_WORKAROUND does not apply
  1807 00000692 F3AB                    	rep stosw		; initialize error info
  1808 00000694 FC                      	cld
  1809 00000695 59                      	pop cx
  1810 00000696 C3                      	retn
  1811                                  
  1812                                  
  1813                                  gg_restorepoints_and_init_error_info:
  1814 00000697 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 0000069A 89CE                    	mov si, cx
  1838 0000069C 01F6                    	add si, si
  1839 0000069E 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 000006A0 01F6                    	add si, si		; * 8
  1848 000006A2 01CE                    	add si, cx		; * 9
  1849                                  %else
  1850                                   %error Unexpected breakpoint size
  1851                                  %endif
  1852 000006A4 81C6[F7FF]              	add si, g_bplist.bp - BPSIZE	; -> last point in list (first to restore)
  1853                                  
  1854 000006A8 F8                      	clc			; assume success
  1855 000006A9 51                      	push cx
  1856 000006AA 9C                      	pushf
  1857 000006AB E329                    	jcxz .done		; nothing to do -->
  1858                                  .loop:
  1859 000006AD E8E400                  	call gg_writepoints_restore	; Restore breakpoint bytes.
  1860 000006B0 7324                    	jnc .done		; successful -->
  1861 000006B2 5A                      	pop dx			; discard flags
  1862 000006B3 5B                      	pop bx
  1863 000006B4 53                      	push bx
  1864 000006B5 9C                      	pushf			; store (CY) flags
  1865                                  
  1866 000006B6 50                      	push ax
  1867 000006B7 89F7                    	mov di, si
  1868 000006B9 81EF[0900]              	sub di, BPSIZE+g_bplist.bp
  1869                                  %if BPSIZE == 5 || BPSIZE == 6 || BPSIZE == 9
  1870 000006BD 89F8                    	mov ax, di
  1871 000006BF 31D2                    	xor dx, dx
  1872 000006C1 BF0900                  	mov di, BPSIZE
  1873 000006C4 F7F7                    	div di
  1874 000006C6 89C7                    	mov di, ax		; di = 0-based point index
  1875 000006C8 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 000006CA 29DF                    	sub di, bx
  1882 000006CC 29DF                    	sub di, bx
  1883 000006CE 8F03                    	pop word [bp+di]	; store error info
  1884 000006D0 49                      	dec cx			; exclude the failed point
  1885 000006D1 83EE12                  	sub si, 2*BPSIZE	; -> the point _before_ failed one
  1886 000006D4 EBD7                    	jmp short .loop
  1887                                  .done:
  1888 000006D6 9D                      	popf			; get flags. CY if any couldn't be restored
  1889 000006D7 59                      	pop cx			; restore cx
  1890 000006D8 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 000006D9 16                      	push ss
  1905 000006DA 07                      	pop es
  1906 000006DB 89EF                    	mov di, bp
  1907 000006DD 31C0                    	xor ax, ax
  1908 000006DF 51                      	push cx
  1909 000006E0 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  1910 000006E3 F3AB                    	rep stosw
  1911 000006E5 59                      	pop cx
  1912 000006E6 C3                      	retn
  1913                                  
  1914                                  
  1915                                  bb_restorepoints_and_init_error_info:
  1916 000006E7 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 000006EA F8                      	clc			; assume success
  1940 000006EB 9C                      	pushf
  1941 000006EC E30F                    	jcxz .done
  1942                                  .loop:
  1943 000006EE E81400                  	call bb_writepoints_restore
  1944 000006F1 730A                    	jnc .done
  1945 000006F3 5A                      	pop dx			; (discard flags)
  1946 000006F4 9C                      	pushf			; store (CY) flags
  1947                                  				; cx = index of point that failed to write
  1948                                  				; ah = reason, al = new byte value (reason 3)
  1949 000006F5 89CF                    	mov di, cx
  1950 000006F7 01FF                    	add di, di
  1951 000006F9 8903                    	mov word [bp + di], ax	; store error info
  1952 000006FB EBF1                    	jmp .loop
  1953                                  
  1954                                  .done:
  1955 000006FD 9D                      	popf			; CF
  1956 000006FE 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 000006FF 31C9                    	xor cx, cx
  1973 00000701 BF0100                  	mov di, 1
  1974 00000704 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 00000705 31FF                    	xor di, di		; (NC)
  1993                                  bb_wp:
  1994                                  	lframe near
  1995 00000707 5589E5                  	lenter
  1996                                  	lvar	word, is_write
  1997 0000070A 57                      	 push di
  1998                                  
  1999 0000070B F646FE01                	test byte [bp + ?is_write], 1
  2000                                  				; (NC) is it writing ?
  2001 0000070F 7459                    	jz .next		; no, is restoring, first decrement cx -->
  2002                                  
  2003                                  .loop:
  2004 00000711 89C8                    	mov ax, cx
  2005 00000713 E8(0000)                	call calcpointbit	; bx = index, ah = value
  2006 00000716 84A7[0000]              	test byte [b_bplist.used_mask+bx], ah
  2007                                  				; (NC)
  2008 0000071A 744E                    	jz .next
  2009 0000071C 84A7[0000]              	test byte [b_bplist.disabled_mask+bx], ah
  2010                                  				; (NC)
  2011 00000720 7548                    	jnz .next
  2012                                  
  2013 00000722 89CE                    	mov si, cx
  2014 00000724 01F6                    	add si, si
  2015 00000726 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 00000728 01F6                    	add si, si		; * 8
  2024 0000072A 01CE                    	add si, cx		; * 9
  2025                                  %else
  2026                                   %error Unexpected breakpoint size
  2027                                  %endif
  2028 0000072C 81C6[0000]              	add si, b_bplist.bp	; -> point
  2029                                  
  2030 00000730 E866FE                  	call gg_bb_lods_bp_linear
  2031                                  				; dx:ax = linear address
  2032                                  
  2033 00000733 E8B700                  	call gg_bb_check_is_first
  2034 00000736 7332                    	jnc .next		; (NC)
  2035                                  
  2036 00000738 E80803                  	call getsegmented	; bx:(e)dx = segmented address
  2037                                  %if BPSIZE == 6
  2038                                  	lodsw			; skip word offset
  2039                                  %elif BPSIZE == 9
  2040 0000073B AD                      	lodsw
  2041 0000073C AD                      	lodsw			; skip dword offset
  2042                                  %endif
  2043 0000073D AC                      	lodsb			; get byte to write
  2044 0000073E B402                    	mov ah, 2
  2045 00000740 723E                    	jc .return		; not in PM anymore/address not available --> (CY)
  2046 00000742 F646FE01                	test byte [bp + ?is_write], 1
  2047                                  				; writing?
  2048 00000746 7517                    	jnz .forward_nocheck	; yes -->
  2049                                  
  2050                                  .backward_check:
  2051 00000748 50                      	push ax
  2052 00000749 E8(0000)                	call readmem		; read current byte
  2053 0000074C 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  2054 0000074E B483                    	mov ah, 83h		; (80h = error occurred while restoring)
  2055 00000750 F9                      	stc
  2056 00000751 752D                    	jne .return_discard	; nope --> (CY)
  2057 00000753 58                      	pop ax
  2058 00000754 E8(0000)                	call writemem		; return the byte to its original value
  2059 00000757 7211                    	jc .next		; failed --> (CY, handled there)
  2060 00000759 C644FFCC                	mov byte [si-1], 0CCh	; reset stored point
  2061 0000075D EB0B                    	jmp short .next
  2062                                  
  2063                                  .forward_nocheck:
  2064                                  %if _DELAY_BEFORE_BP
  2065 0000075F E887FE                  	call delay_before_bp
  2066                                  %endif
  2067 00000762 E8(0000)                	call writemem
  2068 00000765 7203                    	jc .next
  2069 00000767 8844FF                  	mov byte [si-1], al	; save the previous byte there
  2070                                  .next:
  2071 0000076A B401                    	mov ah, 1		; (in case of error)
  2072 0000076C 7212                    	jc .return		; failed to write --> (CY)
  2073                                  
  2074 0000076E F646FE01                	test byte [bp + ?is_write], 1
  2075 00000772 7505                    	jnz .is_write_next
  2076 00000774 49                      	dec cx			; restore: decrement index
  2077 00000775 799A                    	jns .loop		; decremented to 0FFFFh ?  no, loop -->
  2078 00000777 EB06                    	jmp .return_NC
  2079                                  
  2080                                  .is_write_next:
  2081 00000779 41                      	inc cx			; write: increment index
  2082 0000077A 83F910                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  2083                                  				; above last ?
  2084 0000077D 7292                    	jb .loop		; no, loop -->
  2085                                  .return_NC:
  2086 0000077F F8                      	clc
  2087                                  .return:
  2088                                  .return_discard:
  2089 00000780 730A                    	jnc .ret
  2090                                  
  2091 00000782 F646FE01                	test byte [bp + ?is_write], 1
  2092                                  				; restoring ?
  2093 00000786 7503                    	jnz .ret_CY		; no -->
  2094 00000788 80CC80                  	or ah, 80h		; error occurred while restoring
  2095                                  .ret_CY:
  2096 0000078B F9                      	stc
  2097                                  .ret:
  2098 0000078C 89EC5D                  	lleave
  2099 0000078F 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 00000790 BF0100                  	mov di, 1
  2117 00000793 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 00000794 31FF                    	xor di, di		; (NC)
  2131                                  gg_wp:
  2132 00000796 E348                    	jcxz .return		;if nothing to do --> (still NC from xor/test)
  2133                                  .loop:
  2134 00000798 E8FEFD                  	call gg_bb_lods_bp_linear
  2135                                  				; dx:ax = linear address
  2136                                  
  2137 0000079B E84F00                  	call gg_bb_check_is_first
  2138 0000079E 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 000007A0 83C605                  	add si, 5		; skip dword offset and byte content
  2147                                  %endif
  2148                                  				; BPSIZE implied
  2149                                  
  2150 000007A3 85FF                    	test di, di		; (NC)
  2151 000007A5 7533                    	jnz .next		; going forward -->
  2152 000007A7 EB23                    	jmp .next_lea_si	; (NC)
  2153                                  
  2154                                  		; Handle this breakpoint.
  2155                                  @@:
  2156 000007A9 E89702                  	call getsegmented	; bx:(e)dx = segmented address
  2157                                  %if BPSIZE == 6
  2158                                  	lodsw			; skip word offset
  2159                                  %elif BPSIZE == 9
  2160 000007AC AD                      	lodsw
  2161 000007AD AD                      	lodsw			; skip dword offset
  2162                                  %endif
  2163 000007AE AC                      	lodsb			; get byte to write
  2164 000007AF B402                    	mov ah, 2
  2165 000007B1 722D                    	jc .return		; not in PM anymore/address not available --> (CY)
  2166 000007B3 85FF                    	test di, di		; writing?
  2167 000007B5 751A                    	jnz .forward_nocheck	; yes -->
  2168                                  
  2169                                  .backward_check:
  2170 000007B7 50                      	push ax
  2171 000007B8 E8(0000)                	call readmem		; read current byte
  2172 000007BB 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  2173 000007BD B483                    	mov ah, 83h		; (80h = error occurred while restoring)
  2174 000007BF F9                      	stc
  2175 000007C0 7529                    	jne .return_discard	; nope --> (CY)
  2176 000007C2 58                      	pop ax
  2177 000007C3 E8(0000)                	call writemem		; return the byte to its original value
  2178 000007C6 7212                    	jc .next		; failed --> (CY, handled there)
  2179 000007C8 C644FFCC                	mov byte [si-1], 0CCh	; reset stored point
  2180                                  .next_lea_si:
  2181 000007CC 8D74EE                  	lea si, [si-2*BPSIZE]	; adjust (for reverse writing)
  2182 000007CF EB09                    	jmp short .next
  2183                                  
  2184                                  .forward_nocheck:
  2185                                  %if _DELAY_BEFORE_BP
  2186 000007D1 E815FE                  	call delay_before_bp
  2187                                  %endif
  2188 000007D4 E8(0000)                	call writemem
  2189 000007D7 8844FF                  	mov byte [si-1], al	; save the previous byte there
  2190                                  .next:
  2191 000007DA B401                    	mov ah, 1		; (in case of error)
  2192 000007DC 7202                    	jc .return		; failed to write --> (CY)
  2193 000007DE E2B8                    	loop .loop
  2194                                  .return:			; (NC)
  2195 000007E0 730A                    	jnc .ret
  2196                                  
  2197 000007E2 85FF                    	test di, di		; restoring ?
  2198 000007E4 7503                    	jnz .ret_CY		; no -->
  2199 000007E6 80CC80                  	or ah, 80h		; error occurred while restoring
  2200                                  .ret_CY:
  2201 000007E9 F9                      	stc
  2202 000007EA 52                      	push dx			; (counteract effect of pop)
  2203                                  .return_discard:
  2204 000007EB 5A                      	pop dx
  2205                                  .ret:
  2206 000007EC 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 000007ED F606[0000]07            	testopt [internalflags2], 		dif2_gg_is_first | dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  2227 000007F2 7418                    	jz .continue
  2228                                  
  2229 000007F4 3906[0000]              	cmp [gg_first_cseip_linear], ax
  2230 000007F8 7514                    	jne .is_not_first
  2231 000007FA 3916[0200]              	cmp [gg_first_cseip_linear + 2], dx
  2232 000007FE 750E                    	jne .is_not_first
  2233                                  
  2234                                  .is_first:
  2235 00000800 800E[0000]10            	setopt [internalflags2], dif2_gg_first_detected
  2236 00000805 F606[0000]04            	testopt [internalflags2], dif2_gg_skip_cseip
  2237 0000080A 7509                    	jnz .skip
  2238                                  .continue:
  2239 0000080C F9                      	stc
  2240 0000080D C3                      	retn
  2241                                  
  2242                                  .is_not_first:
  2243 0000080E F606[0000]02            	testopt [internalflags2], dif2_gg_skip_non_cseip
  2244 00000813 74F7                    	jz .continue
  2245                                  .skip:
  2246 00000815 F8                      	clc
  2247 00000816 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 00000817 53                      	push bx
  2255 00000818 51                      	push cx
  2256 00000819 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 0000081A BF[0000]                	mov di, line_out
  2263 0000081D E80700                  	call ordinalbyte
  2264 00000820 E8(0000)                	call putsline
  2265 00000823 5A                      	pop dx
  2266 00000824 59                      	pop cx
  2267 00000825 5B                      	pop bx
  2268 00000826 C3                      	retn
  2269                                  
  2270                                  
  2271                                  ordinalbyte:
  2272 00000827 E8(0000)                	call decbyte
  2273 0000082A 8B45FE                  	mov ax, [di - 2]	; al = lower address, higher decimal digit
  2274                                  				; ah = higher address, lower decimal digit
  2275 0000082D 3C31                    	cmp al, '1'
  2276 0000082F 7417                    	je .gotsuf_th		; 11th, 12th, 13th or other teen -->
  2277 00000831 BA7374                  	mov dx, "st"
  2278 00000834 80FC31                  	cmp ah, '1'
  2279 00000837 7412                    	je .gotsuf		; if low digit was one -->
  2280 00000839 BA6E64                  	mov dx, "nd"
  2281 0000083C 80FC32                  	cmp ah, '2'
  2282 0000083F 740A                    	je .gotsuf		; if low digit was two -->
  2283 00000841 B272                    	mov dl, 'r'
  2284 00000843 80FC33                  	cmp ah, '3'
  2285 00000846 7403                    	je .gotsuf		; if low digit was three -->
  2286                                  .gotsuf_th:
  2287 00000848 BA7468                  	mov dx, "th"
  2288                                  .gotsuf:
  2289 0000084B 89D0                    	mov ax, dx
  2290 0000084D AB                      	stosw
  2291 0000084E 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 0000084F E8CC01                  	call resetmode
  2307                                  %endif
  2308 00000852 31FF                    	xor di, di
  2309 00000854 31C9                    	xor cx, cx
  2310 00000856 16                      	push ss
  2311 00000857 07                      	pop es
  2312 00000858 BE[0000]                	mov si, b_bplist.bp
  2313                                  .loop:
  2314 0000085B 8B03                    	mov ax, word [bp + di]
  2315 0000085D F6C47F                  	test ah, 7Fh		; failed ?
  2316 00000860 7414                    	jz .next
  2317 00000862 51                      	push cx
  2318 00000863 57                      	push di
  2319                                  				; cx = 0-based index
  2320 00000864 FF7402                  	 push word [si + 2]
  2321 00000867 FF34                    	 push word [si]		; stack: linear address
  2322 00000869 8A5C08                  	mov bl, byte [si + BPSIZE - 1]
  2323                                  				; bl = what we tried to restore
  2324 0000086C B740                    	mov bh, 40h		; bh = 40h (bb)
  2325 0000086E 80CC80                  	or ah, 80h		; ah & 80h = set (is restore)
  2326 00000871 E8AD0C                  	call display_breakpoint_failure
  2327 00000874 5F                      	pop di
  2328 00000875 59                      	pop cx
  2329                                  .next:
  2330 00000876 83C609                  	add si, BPSIZE
  2331 00000879 AF                      	scasw			; di += 2
  2332 0000087A 41                      	inc cx
  2333 0000087B 83F910                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  2334 0000087E 72DB                    	jb .loop
  2335                                  .end:
  2336 00000880 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 00000881 E89A01                  	call resetmode
  2352                                  %endif
  2353 00000884 89CF                    	mov di, cx
  2354 00000886 01FF                    	add di, di
  2355 00000888 F7DF                    	neg di
  2356 0000088A 16                      	push ss
  2357 0000088B 07                      	pop es
  2358 0000088C BB0000                  	mov bx, 0
  2359 0000088F BE[0000]                	mov si, g_bplist.bp
  2360 00000892 E325                    	jcxz .end
  2361                                  .loop:
  2362 00000894 8B03                    	mov ax, word [bp+di]
  2363 00000896 F6C47F                  	test ah, 7Fh		; failed?
  2364 00000899 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 0000089B 53                      	push bx
  2371 0000089C 57                      	push di
  2372 0000089D 89D9                    	mov cx, bx		; cx = 0-based index
  2373 0000089F FF7402                  	 push word [si + 2]
  2374 000008A2 FF34                    	 push word [si]		; stack: linear address
  2375 000008A4 8A5C08                  	mov bl, byte [si + BPSIZE - 1]
  2376                                  				; bl = what we tried to restore
  2377 000008A7 B780                    	mov bh, 80h		; bh = 80h (gg)
  2378 000008A9 80CC80                  	or ah, 80h		; ah & 80h = set (is restore)
  2379 000008AC E8720C                  	call display_breakpoint_failure
  2380 000008AF 5F                      	pop di
  2381 000008B0 5B                      	pop bx
  2382                                  .next:
  2383 000008B1 43                      	inc bx			; increment counter
  2384 000008B2 83C609                  	add si, BPSIZE		; -> next point
  2385 000008B5 47                      	inc di
  2386 000008B6 47                      	inc di			; di+bp-> next error info
  2387 000008B7 75DB                    	jnz .loop		; not yet at end -->
  2388                                  .end:
  2389 000008B9 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 000008BA 66                      	_386_PM_o32		; or ecx, byte -1
  2402 000008BB 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 000008BE 8B1E[0000]              	mov bx, [reg_cs]	; bx = cs
  2414 000008C2 66                      	_386_PM_o32
  2415 000008C3 8B16[0000]              	mov dx, [reg_eip]	; (e)dx = (e)ip
  2416 000008C7 66                      	_386_PM_o32
  2417 000008C8 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 000008CA 57                      	push di
  2440 000008CB BF[0000]                	mov di, test_d_b_bit
  2441 000008CE E82300                  	call getlinear_common
  2442 000008D1 5F                      	pop di
  2443 000008D2 C3                      	retn
  2444                                  
  2445                                  getlinear_high_limit: section_of_function
  2446 000008D3 57                      	push di
  2447 000008D4 BF[0000]                	mov di, test_high_limit
  2448 000008D7 E81A00                  	call getlinear_common
  2449 000008DA 5F                      	pop di
  2450 000008DB C3                      	retn
  2451                                  
  2452                                  getlinear_32bit: section_of_function
  2453 000008DC 57                      	push di
  2454 000008DD BF[E508]                	mov di, .always_NZ
  2455 000008E0 E81100                  	call getlinear_common
  2456 000008E3 5F                      	pop di
  2457 000008E4 C3                      	retn
  2458                                  
  2459                                  .always_NZ:
  2460 000008E5 85FF                    	test di, di
  2461 000008E7 C3                      	retn
  2462                                  
  2463                                  section_of getlinear_16bit
  2464                                  getlinear_16bit: section_of_function
  2465 000008E8 57                      	push di
  2466 000008E9 BF[F108]                	mov di, .always_ZR
  2467 000008EC E80500                  	call getlinear_common
  2468 000008EF 5F                      	pop di
  2469 000008F0 C3                      	retn
  2470                                  
  2471                                  .always_ZR:
  2472 000008F1 39FF                    	cmp di, di
  2473 000008F3 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 000008F4 E82701                  	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 000008F7 53                      	 push bx
  2526                                  %if _PM
  2527 000008F8 E8(0000)                	call ispm
  2528 000008FB 7520                    	jnz .rm
  2529 000008FD B80600                  	mov ax, 0006h
  2530 00000900 51                      	 push cx
  2531 00000901 52                      	push dx
  2532 00000902 CD31                    	int 31h			; get selector base address into cx:dx
  2533 00000904 58                      	pop ax			; (edxh:)ax = offset, cx:dx = base
  2534 00000905 7213                    	jc .return_cx_bx
  2535                                  
  2536 00000907 FFD7                    _386	call di
  2537 00000909 7406                    _386	jz .16
  2538 0000090B 6652                    _386	push edx
  2539 0000090D 5B                      _386	pop bx
  2540 0000090E 5B                      _386	pop bx			; bx = high word edx (in 32-bit PM segment)
  2541 0000090F EB02                    _386	jmp .32
  2542                                  .16:				; bx:ax = offset
  2543 00000911 31DB                    	xor bx, bx		; 16-bit PM segment, clear offset high word
  2544                                  .32:
  2545 00000913 01D0                    	add ax, dx
  2546 00000915 11CB                    	adc bx, cx		; add the base
  2547 00000917 87DA                    	xchg bx, dx		; dx:ax = 32-bit linear address
  2548 00000919 F8                      	clc
  2549                                  
  2550                                  .return_cx_bx:
  2551 0000091A 59                      	 pop cx
  2552 0000091B 5B                      	 pop bx
  2553 0000091C C3                      	retn
  2554                                  .rm:
  2555                                  %endif
  2556 0000091D 89D8                    	mov ax, bx
  2557 0000091F 51                      	push cx
  2558 00000920 B104                    	mov cl, 4
  2559 00000922 D3C0                    	rol ax, cl
  2560 00000924 59                      	pop cx
  2561 00000925 BBF0FF                  	mov bx, 0FFF0h
  2562 00000928 21C3                    	and bx, ax		; bx = low word adjustment
  2563 0000092A 83E00F                  	and ax, byte 0Fh	; ax = higher bits which don't fit in the low word
  2564 0000092D 01DA                    	add dx, bx
  2565 0000092F 83D000                  	adc ax, byte 0
  2566 00000932 92                      	xchg ax, dx		; dx:ax = 21-bit linear address
  2567 00000933 F606[0100]10            	testopt [internalflags], debuggeeA20
  2568 00000938 7503                    	jnz .return_bx		; A20 line enabled, no need to adjust (NC)
  2569 0000093A 80E2EF                  	and dl, ~10h		; clear corresponding bit of the address if it was set (NC)
  2570                                  .return_bx:
  2571 0000093D 5B                      	 pop bx
  2572 0000093E 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 0000093F E8DC00                  	call resetmode
  2589                                  %endif
  2590                                  %if !_LOADER
  2591 00000942 66                      	_386_PM_o32	; or dword
  2592 00000943 830E[0000]FF            	or word [bp_offset], strict byte -1
  2593                                  %endif
  2594 00000948 E8(0000)                	call skipcomm0
  2595 0000094B 3C40                    	cmp al, '@'
  2596 0000094D 7534                    	jne .at_not
  2597 0000094F AC                      	lodsb			; insure we have a blank or opening parens
  2598 00000950 3C28                    	cmp al, '('
  2599 00000952 740A                    	je .at
  2600 00000954 3C09                    	cmp al, 9
  2601 00000956 7406                    	je .at
  2602 00000958 3C20                    	cmp al, 32
  2603 0000095A 7402                    	je .at
  2604 0000095C EB22                    	jmp .at_not_reload	; assume the @ is part of a symbol
  2605                                  
  2606                                  .at:
  2607 0000095E E8(0000)                	call skipwh0
  2608 00000961 3C28                    	cmp al, '('
  2609 00000963 7512                    	jne .at_not_paren
  2610                                  
  2611 00000965 AC                      	lodsb
  2612 00000966 E8(0000)EB02[0000]      	nearcall getdword
  2613 0000096D E8(0000)                	call skipwh0
  2614 00000970 3C29                    	cmp al, ')'
  2615 00000972 7529                    	jne .error
  2616 00000974 AC                      	lodsb
  2617                                  
  2618 00000975 EB07                    	jmp .at_got
  2619                                  
  2620                                  .at_not_paren:
  2621 00000977 E8(0000)EB02[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 0000097E F8                      	clc
  2630 0000097F C3                      	retn
  2631                                  
  2632                                  .at_not_reload:
  2633 00000980 4E                      	dec si
  2634 00000981 4E                      	dec si
  2635 00000982 AC                      	lodsb
  2636                                  .at_not:
  2637 00000983 E8(0000)EB02[0000]      	nearcall getaddrX
  2638                                  %if _PM
  2639 0000098A 8326[0200]00            _no386	and word [bp_offset + 2], 0
  2640                                  %endif
  2641                                  %if !_LOADER
  2642 0000098F 66                      	_386_PM_o32		; mov dword [bp_offset], edx
  2643 00000990 8916[0000]              	mov word [bp_offset], dx
  2644                                  %endif
  2645 00000994 50                      	push ax
  2646 00000995 E83BFF                  	call getlinear_high_limit
  2647 00000998 93                      	xchg bx, ax	; dx:bx = linear
  2648 00000999 87D3                    	xchg dx, bx	; bx:dx = linear
  2649 0000099B 58                      	pop ax		; al = next character
  2650 0000099C C3                      	retn
  2651                                  
  2652                                  .error:
  2653 0000099D F9                      	stc
  2654 0000099E 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 0000099F A1[0000]                	mov ax, [tpg_possible_breakpoint]
  2669 000009A2 8B16[0200]              	mov dx, [tpg_possible_breakpoint + 2]
  2670                                  			; dx:ax = stored possible breakpoint address
  2671 000009A6 F606[0100]01            	testopt [internalflags2], dif2_tpg_have_bp
  2672 000009AB 7511                    	jnz .retn	; (NC) if already stored -->
  2673 000009AD E80AFF                  	call get_cseip_minus_1_linear
  2674                                  			; dx:ax = linear address at cs:(e)ip - 1
  2675 000009B0 720C                    	jc .retn	; (CY) if getlinear failed -->
  2676 000009B2 A3[0000]                	mov [tpg_possible_breakpoint], ax
  2677 000009B5 8916[0200]              	mov [tpg_possible_breakpoint + 2], dx
  2678                                  			; store for later use
  2679 000009B9 800E[0100]01            	setopt [internalflags2], dif2_tpg_have_bp
  2680                                  			; (NC)
  2681                                  .retn:
  2682 000009BE 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 000009BF 6631DB                  _386	xor ebx, ebx		; clear ebxh
  2709 000009C2 89E3                    	mov bx, sp
  2710 000009C4 6631FF                  _386	xor edi, edi		; clear edih
  2711 000009C7 BF[EE09]                	mov di, .back_after_switch
  2712 000009CA E8(0000)                	call ispm
  2713 000009CD 740F                    	jz .pm
  2714                                  .r86m:
  2715                                  d4	call d4message
  2716                                  d4	asciz "In switchmode.r86m",13,10
  2717 000009CF A1[0000]                	mov ax, [dssel]		; switch rm -> pm
  2718 000009D2 8B36[0000]              	mov si, [code_sel]
  2719 000009D6 89C2                    	mov dx, ax
  2720 000009D8 89C1                    	mov cx, ax
  2721 000009DA FF2E[0000]              	jmp far [dpmi_rm2pm]
  2722                                  .pm:
  2723                                  d4	call d4message
  2724                                  d4	asciz "In switchmode.pm",13,10
  2725 000009DE A1[0000]                	mov ax, [pspdbg]	; switch pm -> rm
  2726 000009E1 8B36[0000]              	mov si, [code_seg]
  2727 000009E5 89C2                    	mov dx, ax
  2728 000009E7 89C1                    	mov cx, ax
  2729 000009E9 66                      	_386_o32	; jmp far dword [dpmi_pm2rm]
  2730 000009EA FF2E[0000]              	jmp far [dpmi_pm2rm]
  2731                                  
  2732                                  .back_after_switch:
  2733 000009EE 8036[0000]02            	xor byte [pm_2_86m_0], 2
  2734 000009F3 8036[0100]08            	xoropt [internalflags], protectedmode
  2735                                  d4	call d4message
  2736                                  d4	asciz "In switchmode.back_after_switch",13,10
  2737 000009F8 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 000009F9 F606[0200]20            	testopt [internalflags], switchbuffer
  2746 000009FE 741B                    	jz .return		; no need to call -->
  2747 00000A00 66                      	_386_o32	; xor edi, edi
  2748 00000A01 31FF                    	xor di, di
  2749 00000A03 E8(0000)                	call ispm
  2750 00000A06 740A                    	jz .pm
  2751                                  .r86m:
  2752                                  d4	call d4message
  2753                                  d4	asciz "In sr_state.r86m",13,10
  2754 00000A08 8E06[0200]              	mov es, word [auxbuff_segorsel + soaSegment]
  2755 00000A0C FF1E[0000]              	call far [dpmi_rmsav]
  2756 00000A10 EB09                    	jmp .return
  2757                                  
  2758                                  .pm:
  2759                                  d4	call d4message
  2760                                  d4	asciz "In sr_state.pm",13,10
  2761 00000A12 8E06[0400]              	mov es, word [auxbuff_segorsel + soaSelector]
  2762 00000A16 66                      	_386_o32	; call far dword [dpmi_pmsav]
  2763 00000A17 FF1E[0000]              	call far [dpmi_pmsav]
  2764                                  .return:
  2765 00000A1B 16                      	push ss
  2766 00000A1C 07                      	pop es
  2767 00000A1D 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 00000A1E 9C                      	pushf
  2780 00000A1F F606[0200]08            	testopt [internalflags], modeswitched	; switched mode previously ?
  2781 00000A24 741A                    	jz .return		; no -->
  2782                                  d4	call d4message
  2783                                  d4	asciz "In resetmode (actually resetting)",13,10
  2784                                  subcpu 286
  2785 00000A26 66                      	_386_o32
  2786 00000A27 60                      	pusha
  2787 00000A28 E894FF                  	call switchmode 	; switch back to the mode we were entered in (RM)
  2788 00000A2B B001                    	mov al, 1
  2789 00000A2D E8C9FF                  	call sr_state		; restore state
  2790 00000A30 E8ED0E                  	call handle_mode_changed		; ! called with flag set
  2791 00000A33 8026[0200]F7            	clropt [internalflags], modeswitched	; reset the flag
  2792 00000A38 16                      _386	push ss
  2793 00000A39 0FA9                    _386	pop gs
  2794 00000A3B 16                      _386	push ss
  2795 00000A3C 0FA1                    _386	pop fs
  2796 00000A3E 66                      	_386_o32
  2797 00000A3F 61                      	popa
  2798                                  subcpureset
  2799                                  .return:
  2800 00000A40 9D                      	popf
  2801 00000A41 FB                      	sti
  2802 00000A42 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 00000A43 E8(0000)                	call ispm
  2848 00000A46 7520                    	jnz .rm
  2849                                  .pm:
  2850 00000A48 51                      	push cx
  2851 00000A49 8B1E[0000]              	mov bx, word [scratchsel]
  2852 00000A4D 92                      	xchg ax, dx
  2853 00000A4E 91                      	xchg ax, cx		; cx:dx = linear address
  2854 00000A4F B80700                  	mov ax, 0007h
  2855 00000A52 CD31                    	int 31h			; set base to the address
  2856 00000A54 59                      	pop cx
  2857 00000A55 7248                    	jc .invalid
  2858                                   %if 1
  2859 00000A57 51                      	push cx
  2860 00000A58 B80800                  	mov ax, 0008h
  2861 00000A5B 31C9                    	xor cx, cx
  2862 00000A5D 31D2                    	xor dx, dx
  2863 00000A5F CD31                    	int 31h			; set limit to zero (access to one byte only)
  2864 00000A61 59                      	pop cx
  2865 00000A62 723B                    	jc .invalid
  2866                                   %endif
  2867 00000A64 66                      	_386_o32	; xor edx, edx
  2868 00000A65 31D2                    	xor dx, dx		; bx:(e)dx = selector:offset (using scratchsel with the address as base)
  2869 00000A67 C3                      	retn			; (NC)
  2870                                  %endif
  2871                                  .rm:
  2872 00000A68 83FA10                  	cmp dx, byte 10h	; check for address space
  2873 00000A6B 7249                    	jb .nothma		; below HMA, normal access -->
  2874 00000A6D 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 00000A6F F606[0200]04            	testopt [internalflags], canswitchmode
  2879 00000A74 7429                    	jz .invalid		; can't switch to PM -->
  2880                                  .switchmodes:
  2881 00000A76 66                      	_386_o32
  2882 00000A77 56                      	push si
  2883 00000A78 66                      	_386_o32
  2884 00000A79 57                      	push di
  2885 00000A7A 66                      	_386_o32
  2886 00000A7B 51                      	push cx
  2887 00000A7C 66                      	_386_o32
  2888 00000A7D 55                      	push bp
  2889 00000A7E 52                      	push dx
  2890 00000A7F 50                      	push ax
  2891                                  d4	call d4message
  2892                                  d4	asciz "In getsegmented.switchmodes (switching to access memory beyond 1088 KiB)",13,10
  2893 00000A80 E8770F                  	call remember_mode
  2894 00000A83 800E[0200]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  2895 00000A88 B000                    	mov al, 0
  2896 00000A8A E86CFF                  	call sr_state		; save state
  2897 00000A8D E82FFF                  	call switchmode 	; switch to PM
  2898 00000A90 E88D0E                  	call handle_mode_changed		; ! called with flag set
  2899 00000A93 58                      	pop ax
  2900 00000A94 5A                      	pop dx
  2901 00000A95 66                      	_386_o32
  2902 00000A96 5D                      	pop bp
  2903 00000A97 66                      	_386_o32
  2904 00000A98 59                      	pop cx
  2905 00000A99 66                      	_386_o32
  2906 00000A9A 5F                      	pop di
  2907 00000A9B 66                      	_386_o32
  2908 00000A9C 5E                      	pop si
  2909 00000A9D EBA9                    	jmp .pm
  2910                                  
  2911                                  .invalid:			; the address is inaccessible
  2912                                  %endif
  2913 00000A9F F9                      	stc
  2914 00000AA0 C3                      	retn
  2915                                  
  2916                                  .checkhma:
  2917 00000AA1 83F8F0                  	cmp ax, -10h		; valid offset for HMA ?
  2918 00000AA4 73C9                    	jae .nonrmspace		; no, above HMA -->
  2919 00000AA6 F606[0100]20            	testopt [internalflags], debuggerA20	; A20 on, HMA accessible ?
  2920 00000AAB 74C2                    	jz .nonrmspace		; no, treat as above HMA (DEBUGX) -->
  2921 00000AAD BBFFFF                  	mov bx, 0FFFFh		; the HMA must always be addressed by segment FFFFh
  2922 00000AB0 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 00000AB3 92                      	xchg ax, dx		; bx:dx = segment:offset
  2925 00000AB4 EB11                    	jmp .zero_edxh
  2926                                  
  2927                                  .nothma:
  2928 00000AB6 51                      	push cx
  2929 00000AB7 B104                    	mov cl, 4
  2930 00000AB9 D3CA                    	ror dx, cl		; dx (high 4 bits) = high 4 bits of segment
  2931 00000ABB 89C3                    	mov bx, ax
  2932 00000ABD D3EB                    	shr bx, cl		; bx = low 12 bits of segment
  2933 00000ABF 09DA                    	or dx, bx		; dx = segment
  2934 00000AC1 83E00F                  	and ax, byte 0Fh	; ax = low 4 bits of linear, used as offset (NC)
  2935 00000AC4 92                      	xchg ax, dx
  2936 00000AC5 93                      	xchg ax, bx		; bx:dx = segment:offset
  2937 00000AC6 59                      	pop cx
  2938                                  .zero_edxh:
  2939 00000AC7 660FB7D2                _386_PM	movzx edx, dx
  2940 00000ACB 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 00000ACC 8A64FE                  	mov ah, byte [si - 2]
  2957 00000ACF 80E4DF                  	and ah, TOUPPER
  2958 00000AD2 80FC54                  	cmp ah, 'T'
  2959 00000AD5 7508                    	jne @F
  2960 00000AD7 88C4                    	mov ah, al
  2961 00000AD9 80E4DF                  	and ah, TOUPPER
  2962 00000ADC 80FC4D                  	cmp ah, 'M'
  2963                                  @@:
  2964 00000ADF 7546                    	jne isnotmodeset
  2965 00000AE1 E8(0000)                	call skipcomma
  2966 00000AE4 E8(0000)                	call iseol?
  2967 00000AE7 741A                    	je ismodeget
  2968 00000AE9 E8(0000)EB02[0000]      	nearcall getexpression
  2969 00000AF0 E8(0000)                	call chkeol		; expect end of line here
  2970 00000AF3 09DA                    	or dx, bx
  2971 00000AF5 7507                    	jnz .set		; selected nonzero -->
  2972                                  .clear:				; selected zero
  2973 00000AF7 8026[0000]FD            	clropt [options], traceints
  2974 00000AFC EB05                    	jmp short .get
  2975                                  .set:
  2976 00000AFE 800E[0000]02            	setopt [options], traceints
  2977                                  .get:
  2978                                  ismodeget:
  2979 00000B03 B030                    	mov al, '0'
  2980 00000B05 BE[0000]                	mov si, tmode0
  2981 00000B08 F606[0000]02            	testopt [options], traceints
  2982 00000B0D 7404                    	jz .zero
  2983 00000B0F 40                      	inc ax
  2984 00000B10 BE[0000]                	mov si, tmode1
  2985                                  .zero:
  2986 00000B13 A2[0000]                	mov byte [tmodev], al
  2987 00000B16 BF[0000]                	mov di, line_out
  2988 00000B19 56                      	push si
  2989 00000B1A BE[0000]                	mov si, tmodes
  2990 00000B1D E8(0000)                	call showstring
  2991 00000B20 5E                      	pop si
  2992 00000B21 E8(0000)                	call showstring
  2993 00000B24 E9(0000)                	jmp putsline_crlf
  2994                                  
  2995                                  isnotmodeset:
  2996                                  %if _TSR && (_APPLICATION || _DEVICE)
  2997 00000B27 80FC53                  	cmp ah, 'S'
  2998 00000B2A 750D                    	jne @F
  2999 00000B2C 50                      	push ax
  3000 00000B2D 8A04                    	mov al, byte [si]
  3001 00000B2F 24DF                    	and al, TOUPPER
  3002 00000B31 3C52                    	cmp al, 'R'
  3003 00000B33 58                      	pop ax
  3004 00000B34 7503E96002              	je tsr
  3005                                  @@:
  3006                                  %endif
  3007                                  
  3008                                  %if _RH
  3009 00000B39 E8(0000)                	call enable_rh
  3010                                  %endif
  3011                                  
  3012                                  %if _TTEST
  3013 00000B3C 50                      	push ax
  3014 00000B3D 80FC54                  	cmp ah, 'T'
  3015 00000B40 7516                    	jne @F
  3016 00000B42 8B04                    	mov ax, word [si]
  3017 00000B44 25DFDF                  	and ax, TOUPPER_W
  3018 00000B47 3D4553                  	cmp ax, "ES"
  3019 00000B4A 750C                    	jne @F
  3020 00000B4C 8A4402                  	mov al, byte [si + 2]
  3021 00000B4F 24DF                    	and al, TOUPPER
  3022 00000B51 3C54                    	cmp al, 'T'
  3023 00000B53 7503E9C000              	je ttestcmd
  3024                                  @@:
  3025 00000B58 58                      	pop ax
  3026                                  %endif
  3027                                  
  3028 00000B59 8026[0300]F7            	clropt [internalflags], tt_p
  3029 00000B5E 80FC50                  	cmp ah, 'P'
  3030 00000B61 7506                    	jne @F
  3031 00000B63 AC                      	lodsb
  3032 00000B64 800E[0300]08            	setopt [internalflags], tt_p
  3033                                  @@:
  3034                                  tt0:
  3035                                  %if _RH
  3036 00000B69 E8(0000)                	call enable_rh
  3037                                  %endif
  3038 00000B6C C706[0000][690B]        	mov word [lastcmd], tt0
  3039 00000B72 8026[0100]EF            	clropt [internalflags2], dif2_is_pp
  3040 00000B77 E8C70F                  	call parse_pt		; process arguments
  3041                                  
  3042                                  		; Do it <BX:CX=count> times.
  3043                                  tt1:
  3044 00000B7A 53                      	push bx
  3045 00000B7B 51                      	push cx
  3046                                  
  3047 00000B7C F606[0300]08            	testopt [internalflags], tt_p
  3048 00000B81 744A                    	jz .not_p
  3049                                  
  3050                                  %if _PM
  3051 00000B83 E898FE                  	call resetmode
  3052                                  %endif
  3053 00000B86 BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
  3054 00000B89 8B1E[0000]              	mov bx, word [reg_cs]
  3055 00000B8D 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
  3056 00000B8E 8B36[0000]              	mov si, word [reg_eip]
  3057                                  .pp2:
  3058 00000B92 E8EB0A                  	call pp16		; get next instruction byte into AL
  3059 00000B95 BF[0000]                	mov di, ppbytes
  3060 00000B98 B9[0000]                	mov cx, PPLEN_ONLY_STRING
  3061                                  %if _SYMBOLIC
  3062                                  	mov byte [pp_instruction], al
  3063                                  %endif
  3064 00000B9B F2AE                    	repne scasb
  3065 00000B9D 752E                    	jne .not_p		; if not one of these -->
  3066                                  %if _LINK_COMPAT
  3067 00000B9F 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 00000BA3 A880                    	test al, PP_PREFIX	; prefix ?
  3072 00000BA5 740E                    	jz .pp3			; no -->
  3073 00000BA7 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 00000BA9 FECA                    	dec dl
  3079 00000BAB 75E5                    	jnz .pp2		; if not out of bytes -->
  3080 00000BAD BA[0000]                	mov dx, msg.warnprefix
  3081 00000BB0 E8(0000)                	call putsz
  3082 00000BB3 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 00000BB5 E86906                  _386_PM	call pp_fix32bitflags
  3089 00000BB8 A847                    	test al, PP_VARSIZ | PP_SIZ_MASK
  3090 00000BBA 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 00000BBF E8(0000)                _386_PM	call resetmode_and_test_d_b_bit
  3110 00000BC2 7504                    _386_PM	jnz .32			; full 32-bit offset valid -->
  3111 00000BC4 660FB7F6                _386_PM	movzx esi, si		; clear high word here
  3112                                  .32:
  3113 00000BC8 E81F0A                  	call proceedbreakpoint	; run until the breakpoint is hit
  3114                                  		; This call might return modeswitched.
  3115 00000BCB EB03                    	jmp short @F
  3116                                  
  3117                                  .not_p:
  3118 00000BCD E85A04                  	call traceone		; call common code
  3119                                  @@:
  3120 00000BD0 7303E91604              	jc unexpectedinterrupt	; an unexpected interrupt occured -->
  3121                                  %if _BREAKPOINTS
  3122 00000BD5 BA0000                  	mov dx, 0		; do not skip WHILE
  3123 00000BD8 7416                    	jz @F			; (breakpoint after instruction was hit)
  3124                                  
  3125                                  		; bb breakpoint was hit. dumpregs, then return
  3126 00000BDA E8CB00                  	call handle_bb_hit_pass_match
  3127 00000BDD 7204                    	jc .actual_hit		; actual match ? -->
  3128 00000BDF 741A                    	jz tt2.nodump		; non-silent mode ? -->
  3129 00000BE1 EB0D                    	jmp tt2			; silent mode -->
  3130                                  
  3131                                  .actual_hit:
  3132                                  %if _PM
  3133 00000BE3 E838FE                  	call resetmode
  3134                                  %endif
  3135 00000BE6 E8C6F7                  	call put_deferred_message_silent
  3136 00000BE9 E81A08                  	call dumpregs_extended_silent
  3137 00000BEC 59                      	pop cx
  3138 00000BED 5B                      	pop bx			; (discard counter)
  3139 00000BEE EB1E                    	jmp @FF
  3140                                  @@:
  3141                                  %endif
  3142                                  tt2:
  3143 00000BF0 52                      	push dx
  3144                                  %if _PM
  3145 00000BF1 E82AFE                  	call resetmode
  3146                                  %endif
  3147 00000BF4 E8B8F7                  	call put_deferred_message_silent
  3148 00000BF7 E80C08                  	call dumpregs_extended_silent
  3149                                  				; dump registers
  3150 00000BFA 5A                      	pop dx			; preserve skip WHILE flag
  3151                                  .nodump:
  3152                                  
  3153 00000BFB E85800                  	call tt_handle_while
  3154 00000BFE 59                      	pop cx
  3155 00000BFF 5B                      	pop bx
  3156                                  
  3157 00000C00 83E901                  	sub cx, 1
  3158 00000C03 83DB00                  	sbb bx, 0		; decrement loop counter
  3159                                  
  3160 00000C06 85DB                    	test bx, bx
  3161 00000C08 750B                    	jnz tt1_jmp		; loop -->
  3162 00000C0A 85C9                    	test cx, cx
  3163 00000C0C 7507                    	jnz tt1_jmp		; loop -->
  3164                                  
  3165                                  @@:
  3166                                  %if _PM
  3167 00000C0E E80DFE                  	call resetmode
  3168                                  %endif
  3169 00000C11 E8(0000)                	call silence_dump
  3170                                  
  3171 00000C14 C3                      	retn
  3172                                  
  3173                                  tt1_jmp:
  3174 00000C15 E962FF                  	jmp tt1
  3175                                  
  3176                                  
  3177                                  %if _TTEST
  3178                                  ttestcmd:
  3179 00000C18 58                      	pop ax
  3180 00000C19 46                      	inc si
  3181 00000C1A 46                      	inc si
  3182 00000C1B 46                      	inc si
  3183 00000C1C E8(0000)                	call skipwhite
  3184                                  
  3185                                  .tt0:
  3186 00000C1F C706[0000][1F0C]        	mov word [lastcmd], .tt0
  3187 00000C25 8026[0100]EF            	clropt [internalflags2], dif2_is_pp
  3188 00000C2A E8140F                  	call parse_pt		; process arguments
  3189                                  
  3190                                  		; Do it <BX:CX=count> times.
  3191                                  .tt1:
  3192 00000C2D 53                      	push bx
  3193 00000C2E 51                      	push cx
  3194                                  
  3195                                  .tt2:
  3196                                  %if _PM
  3197 00000C2F E8ECFD                  	call resetmode
  3198                                  %endif
  3199 00000C32 E87AF7                  	call put_deferred_message_silent
  3200 00000C35 E8CE07                  	call dumpregs_extended_silent
  3201                                  				; dump registers
  3202                                  .nodump:
  3203                                  
  3204 00000C38 31D2                    	xor dx, dx
  3205 00000C3A E81900                  	call tt_handle_while
  3206 00000C3D 59                      	pop cx
  3207 00000C3E 5B                      	pop bx
  3208                                  
  3209 00000C3F 83E901                  	sub cx, 1
  3210 00000C42 83DB00                  	sbb bx, 0		; decrement loop counter
  3211                                  
  3212 00000C45 85DB                    	test bx, bx
  3213 00000C47 750B                    	jnz .tt1_jmp		; loop -->
  3214 00000C49 85C9                    	test cx, cx
  3215 00000C4B 7507                    	jnz .tt1_jmp		; loop -->
  3216                                  
  3217                                  @@:
  3218                                  %if _PM
  3219 00000C4D E8CEFD                  	call resetmode
  3220                                  %endif
  3221 00000C50 E8(0000)                	call silence_dump
  3222                                  
  3223 00000C53 C3                      	retn
  3224                                  
  3225                                  .tt1_jmp:
  3226 00000C54 EBD7                    	jmp .tt1
  3227                                  %endif
  3228                                  
  3229                                  
  3230                                  		; INP:	dx = nonzero if to bypass while condition
  3231                                  tt_handle_while:
  3232 00000C56 85D2                    	test dx, dx
  3233 00000C58 7543                    	jnz @F
  3234 00000C5A F606[0300]04            	testopt [internalflags], tt_while
  3235 00000C5F 743C                    	jz @F
  3236                                  
  3237                                  %if _PM
  3238 00000C61 E8BAFD                  	call resetmode
  3239                                  %endif
  3240 00000C64 E83700                  	call .point_to_condition
  3241                                  				; dx = si -> line_out with condition
  3242 00000C67 FF36[0000]              	push word [rc]
  3243 00000C6B 8F06[0000]              	pop word [priorrc]
  3244 00000C6F AC                      	lodsb
  3245 00000C70 E8(0000)EB02[0000]      	nearcall getexpression	; parse stored expression
  3246 00000C77 E8(0000)                	call chkeol
  3247 00000C7A E8(0000)EB02[0000]      	nearcall toboolean	; get boolean
  3248 00000C81 85D2                    	test dx, dx		; true ?
  3249 00000C83 7518                    	jnz @F			; yes, continue -->
  3250                                  
  3251 00000C85 E8(0000)                	call silence_dump
  3252                                  
  3253 00000C88 BA[0000]                	mov dx, msg.while_terminated_before
  3254 00000C8B E8(0000)                	call putsz
  3255 00000C8E E80D00                  	call .point_to_condition
  3256 00000C91 E8(0000)                	call putsz		; display condition
  3257 00000C94 BA[0000]                	mov dx, msg.while_terminated_after
  3258 00000C97 E8(0000)                	call putsz
  3259 00000C9A E9(0000)                	jmp cmd3
  3260                                  
  3261                                  @@:
  3262 00000C9D C3                      	retn
  3263                                  
  3264                                  
  3265                                  .point_to_condition:
  3266 00000C9E 16                      	push ss
  3267 00000C9F 07                      	pop es
  3268 00000CA0 16                      	push ss
  3269 00000CA1 1F                      	pop ds
  3270 00000CA2 BE[0000]                	mov si, while_buffer
  3271 00000CA5 89F2                    	mov dx, si
  3272 00000CA7 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 00000CA8 91                      	xchg ax, cx
  3302                                  
  3303 00000CA9 F606[0100]08            	testopt [internalflags2], dif2_bp_failure
  3304 00000CAE 756C                    	jnz .actual_hit		; after failure, handle as actual hit
  3305                                  
  3306 00000CB0 A801                    	test al, 1		; actual hit ?  else: non-hit, pass or non-pass
  3307 00000CB2 7568                    	jnz .actual_hit		; yes -->
  3308                                  
  3309 00000CB4 A802                    	test al, 2		; at least pass match ?
  3310 00000CB6 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 00000CB8 E863FD                  	call resetmode
  3319                                  %endif
  3320                                  	; call put_deferred_message_loud
  3321 00000CBB BA[0000]                	mov dx, msg.empty_message
  3322 00000CBE 8716[0000]              	xchg dx, word [gg_deferred_message]
  3323 00000CC2 E8(0000)                	call putsz
  3324 00000CC5 BA[0000]                	mov dx, putsline
  3325 00000CC8 E8F1F6                  	call put_bb_deferred_message_calling_dx
  3326                                  
  3327 00000CCB 50                      	push ax
  3328                                  	; call dumpregs_extended_loud
  3329                                  				; (includes handle_serial_flags_ctrl_c)
  3330 00000CCC E8(0000)                	call dumpregs_extended
  3331 00000CCF 58                      	pop ax			; (preserve so the test al, 8 can use it)
  3332                                  .nonpassnonhit:
  3333 00000CD0 E83F07                  	call handle_serial_flags_ctrl_c
  3334                                  
  3335                                  	; al & 4 always set
  3336                                  
  3337 00000CD3 8026[0000]E9            	clropt [internalflags2], 		dif2_gg_skip_non_cseip | dif2_gg_skip_cseip | dif2_gg_first_detected
  3339 00000CD8 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
  3340                                  
  3341 00000CDD FF36[0200]              	push word [gg_next_cseip_linear + 2]
  3342 00000CE1 FF36[0000]              	push word [gg_next_cseip_linear]
  3343 00000CE5 8F06[0000]              	pop word [gg_first_cseip_linear]
  3344 00000CE9 8F06[0200]              	pop word [gg_first_cseip_linear + 2]
  3345                                  
  3346 00000CED A808                    	test al, 8		; not bb hit, is tt/pp hit ?
  3347 00000CEF 751C                    	jnz @FF			; yes -->
  3348                                  
  3349 00000CF1 F706[0000]8010          	testopt [internalflags2], dif2_is_pp | dif2_tpg_keep_proceed_bp, 1
  3350 00000CF7 7502                    	jnz @F
  3351 00000CF9 EB12                    	jmp @FF
  3352                                  
  3353                                  @@:
  3354                                  	lframe near
  3355                                  	lpar dword,	counter
  3356                                  	lpar_return
  3357 00000CFB 5589E5                  	lenter
  3358 00000CFE 83460401                	add word [bp + ?counter], 1
  3359 00000D02 83560600                	adc word [bp + ?counter + 2], 0
  3360 00000D06 5D                      	lleave
  3361 00000D07 BA0100                  	mov dx, 1		; skip WHILE
  3362 00000D0A 38C0                    	cmp al, al		; (NC, ZR)
  3363 00000D0C C3                      	retn
  3364                                  
  3365                                  @@:
  3366 00000D0D 31D2                    	xor dx, dx		; no skip WHILE
  3367 00000D0F A802                    	test al, 2		; displayed pass point ?
  3368 00000D11 7503                    	jnz @F			; yes -->
  3369 00000D13 A8FF                    	test al, -1		; NC, NZ (do not skip dump)
  3370                                  		; al & 0Ch is set so this test is NZ
  3371 00000D15 C3                      	retn
  3372                                  
  3373                                  @@:
  3374 00000D16 F606[0300]10            	testopt [internalflags], tt_silent_mode
  3375                                  				; (NC, ZF is ZR if to skip dump)
  3376 00000D1B C3                      	retn
  3377                                  
  3378                                  .actual_hit:
  3379                                  d5	call d5message
  3380                                  d5	asciz "bb hit",13,10
  3381                                  
  3382 00000D1C 31D2                    	xor dx, dx		; no skip WHILE
  3383 00000D1E F9                      	stc
  3384 00000D1F C3                      	retn
  3385                                  
  3386                                  
  3387                                  %if _ATTACH
  3388                                  attach:
  3389                                   %if _BOOTLDR
  3390 00000D20 F606[0100]40            	testopt [internalflags], nodosloaded
  3391 00000D25 7403E9(0000)            	jnz error
  3392                                   %endif
  3393 00000D2A E8(0000)                	call skipwh0
  3394 00000D2D E8(0000)EB02[0000]      	nearcall getword
  3395 00000D34 E8(0000)                	call chkeol
  3396 00000D37 F606[0200]40            	testopt [internalflags], tsrmode
  3397 00000D3C 750C                    	jnz @F			; resident -->
  3398 00000D3E BA[0000]                	mov dx, msg.notyettsr
  3399 00000D41 B81101                  	mov ax, 0111h
  3400                                  .specificerror:
  3401 00000D44 E8(0000)                	call setrc
  3402 00000D47 E9(0000)                	jmp putsz_error
  3403                                  
  3404                                  @@:
  3405                                   %if _PM
  3406 00000D4A E8(0000)                	call setes2dx
  3407                                   %else
  3408                                  	mov es, dx
  3409                                   %endif
  3410 00000D4D 26813E0000CD20          	cmp word [es:0], 20CDh
  3411 00000D54 7408                    	je @F
  3412 00000D56 BA[0000]                	mov dx, msg.invalidpsp
  3413 00000D59 B81201                  	mov ax, 0112h
  3414 00000D5C EBE6                    	jmp .specificerror
  3415                                  
  3416                                  @@:
  3417 00000D5E 2639161600              	cmp word [es:16h], dx
  3418 00000D63 7508                    	jne @F
  3419 00000D65 BA[0000]                	mov dx, msg.selfownedpsp
  3420 00000D68 B81301                  	mov ax, 0113h
  3421 00000D6B EBD7                    	jmp .specificerror
  3422                                  
  3423                                  @@:
  3424 00000D6D 06                      	push es
  3425 00000D6E 1F                      	pop ds
  3426 00000D6F 16                      	push ss
  3427 00000D70 07                      	pop es
  3428 00000D71 BE0A00                  	mov si, TPIV
  3429 00000D74 BF[0000]                	mov di, psp22
  3430 00000D77 A5                      	movsw
  3431 00000D78 A5                      	movsw				; save Int22
  3432                                   %if _PM
  3433 00000D79 36A1[0000]              	mov ax, word [ss:pspdbg]
  3434                                   %else
  3435                                  	mov ax, ss			; => our process
  3436                                   %endif
  3437 00000D7D C744FC[3C02]            	mov word [ si-4 ], int22
  3438 00000D82 8944FE                  	mov word [ si-2 ], ax		; set pspInt22 (required)
  3439 00000D85 BE1600                  	mov si, 16h
  3440 00000D88 A5                      	movsw				; save parent
  3441 00000D89 8944FE                  	mov word [ si-2 ], ax		; set pspParent
  3442 00000D8C 16                      	push ss
  3443 00000D8D 1F                      	pop ds
  3444 00000D8E 8026[0200]BF            	clropt [internalflags], tsrmode
  3445 00000D93 BA[0000]                	mov dx, msg.nowattached
  3446 00000D96 E9(0000)                	jmp putsz
  3447                                  %endif
  3448                                  
  3449                                  
  3450                                  %if _TSR && (_APPLICATION || _DEVICE)
  3451                                  tsr:
  3452                                   %if _BOOTLDR
  3453 00000D99 F606[0100]40            	testopt [internalflags], nodosloaded
  3454 00000D9E 7403E9(0000)            	jnz error
  3455                                   %endif
  3456 00000DA3 E8(0000)                	call guard_re
  3457 00000DA6 46                      	inc si
  3458 00000DA7 AC                      	lodsb
  3459 00000DA8 E8(0000)                	call chkeol
  3460 00000DAB F606[0200]40            	testopt [internalflags], tsrmode
  3461 00000DB0 7408                    	jz .try			; not yet resident -->
  3462 00000DB2 BA[0000]                	mov dx, msg.alreadytsr
  3463 00000DB5 B81401                  	mov ax, 0114h
  3464 00000DB8 EB5A                    	jmp .specificerror_es
  3465                                  .try:
  3466 00000DBA 8B16[0000]              	mov dx, word [pspdbe]
  3467 00000DBE 8B1E[0000]              	mov bx, word [pspdbg]
  3468 00000DC2 BF0A00                  	mov di, 0Ah
  3469                                  .loop:
  3470                                  %if _PM
  3471 00000DC5 89D1                    	mov cx, dx		; = original segment address
  3472 00000DC7 E8(0000)                	call ispm
  3473 00000DCA 7517                    	jnz .rm
  3474 00000DCC 53                      	push bx
  3475 00000DCD 89D0                    	mov ax, dx
  3476                                  [cpu 286]
  3477 00000DCF C1EA0C                  	shr dx, 12
  3478 00000DD2 C1E004                  	shl ax, 4		; shift to get a 32-bit linear address
  3479                                  __CPU__
  3480 00000DD5 E870FC                  	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 00000DD8 E8(0000)                	call setrmlimit
  3487 00000DDB 89D7                    	mov di, dx		; -> PSP
  3488 00000DDD 89DA                    	mov dx, bx
  3489 00000DDF 5B                      	pop bx
  3490 00000DE0 83C70A                  	add di, byte 0Ah	; -> PSP termination vector
  3491                                  .rm:
  3492                                  %endif
  3493 00000DE3 8EC2                    	mov es, dx
  3494 00000DE5 268B450C                	mov ax, word [es:(di-0Ah)+16h]
  3495 00000DE9 40                      	inc ax
  3496 00000DEA 7422                    	jz .pspnotfound
  3497 00000DEC 48                      	dec ax
  3498 00000DED 741F                    	jz .pspnotfound		; parent is invalid -->
  3499                                  %if _PM
  3500 00000DEF 39C8                    	cmp ax, cx
  3501                                  %else
  3502                                  	cmp ax, dx
  3503                                  %endif
  3504 00000DF1 741B                    	je .pspnotfound		; parent is the process itself -->
  3505 00000DF3 89C2                    	mov dx, ax
  3506 00000DF5 39D8                    	cmp ax, bx
  3507 00000DF7 75CC                    	jne .loop		; parent is not us -->
  3508 00000DF9 26813D[3C02]            	cmp word [es:di], int22
  3509 00000DFE 7506                    	jne .psphooked
  3510 00000E00 26395D02                	cmp word [es:di+2], bx
  3511 00000E04 7416                    	je .found		; correct vector --> (otherwise: hooked)
  3512                                  .psphooked:
  3513 00000E06 BA[0000]                	mov dx, msg.psphooked
  3514 00000E09 B80F01                  	mov ax, 010Fh
  3515 00000E0C EB06                    	jmp short .specificerror_es
  3516                                  .pspnotfound:
  3517 00000E0E BA[0000]                	mov dx, msg.pspnotfound
  3518 00000E11 B81001                  	mov ax, 0110h
  3519                                  .specificerror_es:
  3520 00000E14 E8(0000)                	call setrc
  3521                                  .putsz_es:
  3522 00000E17 16                      	push ss
  3523 00000E18 07                      	pop es
  3524                                  .putsz:
  3525 00000E19 E9(0000)                	jmp putsz
  3526                                  
  3527                                  .found:
  3528 00000E1C BE[0000]                	mov si, psp22
  3529 00000E1F A5                      	movsw
  3530 00000E20 A5                      	movsw			; write our parent's vector
  3531 00000E21 83C708                  	add di, 16h-(0Ah+4)
  3532 00000E24 A5                      	movsw			; write our parent
  3533 00000E25 800E[0200]40            	setopt [internalflags], tsrmode	; note that we are resident
  3534                                  %if _PM
  3535 00000E2A 51                      	push cx
  3536                                  %else
  3537                                  	push es
  3538                                  %endif
  3539 00000E2B BA[0000]                	mov dx, msg.nowtsr1
  3540 00000E2E E8E6FF                  	call .putsz_es
  3541 00000E31 58                      	pop ax
  3542 00000E32 BF[0000]                	mov di, line_out
  3543 00000E35 E8(0000)                	call hexword
  3544 00000E38 E8(0000)                	call putsline
  3545 00000E3B BF[0000]                	mov di, psp22
  3546 00000E3E 31C0                    	xor ax, ax
  3547 00000E40 AB                      	stosw
  3548 00000E41 AB                      	stosw
  3549 00000E42 AB                      	stosw			; clear our parent/int22 fields
  3550 00000E43 BA[0000]                	mov dx, msg.nowtsr2
  3551 00000E46 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 00000E48 E81000                  	call silence_init
  3561 00000E4B E8(0000)                	call putsz		; print string
  3562                                  
  3563                                  silence_exit:
  3564 00000E4E F606[0300]10            	testopt [internalflags], tt_silent_mode
  3565 00000E53 7405                    	jz @F
  3566 00000E55 8026[0300]DF            	clropt [internalflags], tt_silence
  3567                                  @@:
  3568 00000E5A C3                      	retn
  3569                                  
  3570                                  
  3571                                  silence_init:
  3572 00000E5B F606[0300]10            	testopt [internalflags], tt_silent_mode
  3573 00000E60 7405                    	jz @F
  3574 00000E62 800E[0300]20            	setopt [internalflags], tt_silence
  3575                                  @@:
  3576 00000E67 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 00000E68 E8F0FF                  	call silence_init
  3585 00000E6B E8(0000)                	call putsline
  3586 00000E6E 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 00000E70 F606[0200]40            	testopt [options6], opt6_debug_putrunint_early
  3613 00000E75 7402                    	jz @F
  3614 00000E77 CC                      	int3
  3615 00000E78 90                      	nop
  3616                                  @@:
  3617                                  %endif
  3618                                  
  3619                                  %if _AREAS_HOOK_SERVER
  3620 00000E79 66                      	_386_PM_o32		; push ecx
  3621 00000E7A 51                      	push cx
  3622 00000E7B 53                      	push bx
  3623 00000E7C 66                      	_386_PM_o32		; push esi
  3624 00000E7D 56                      	push si
  3625                                  
  3626 00000E7E A1[0000]                	mov ax, word [run_int]
  3627 00000E81 3D[0000]                	cmp ax, int1msg
  3628 00000E84 740F                    	je .end_j
  3629 00000E86 3D[0000]                	cmp ax, int3msg
  3630 00000E89 740A                    	je .end_j
  3631                                  %if _CATCHINT19
  3632 00000E8B 3D[0000]                	cmp ax, int19msg
  3633 00000E8E 7405                    	je .end_j
  3634                                  %endif
  3635 00000E90 3D[0000]                	cmp ax, progtrm
  3636 00000E93 7503                    	jne @F
  3637                                  .end_j:
  3638 00000E95 E92A01                  	jmp .end
  3639                                  
  3640                                  @@:
  3641 00000E98 66                      	_386_PM_o32		; xor ecx, ecx
  3642 00000E99 31C9                    	xor cx, cx
  3643 00000E9B E820FA                  	call get_cseip_ecx_linear
  3644 00000E9E 89D3                    	mov bx, dx		; bx:ax = linear cs:eip
  3645 00000EA0 16                      	push ss
  3646 00000EA1 07                      	pop es
  3647 00000EA2 BF[0000]                	mov di, ddebugareas
  3648 00000EA5 31C9                    	xor cx, cx
  3649                                  
  3650                                  .loop:
  3651                                  %if _PM
  3652 00000EA7 268B551A                	mov dx, word [es:di + areastrucNext + 2]
  3653 00000EAB 268B7D18                	mov di, word [es:di + areastrucNext]
  3654 00000EAF E8(0000)                	call setes2dx
  3655                                  %else
  3656                                  	les di, [es:di + areastrucNext]
  3657                                  	mov dx, es
  3658                                  %endif
  3659 00000EB2 3B16[0000]              	cmp dx, word [pspdbg]
  3660 00000EB6 7503E90701              	je .end
  3661                                  
  3662 00000EBB 52                      	push dx
  3663 00000EBC 57                      	push di
  3664 00000EBD 51                      	push cx
  3665 00000EBE 53                      	push bx
  3666 00000EBF 50                      	push ax
  3667                                  
  3668 00000EC0 57                      	push di
  3669 00000EC1 268B4D24                	mov cx, word [es:di + areastrucFunAmount]
  3670 00000EC5 268B7D26                	mov di, word [es:di + areastrucFunOffset]
  3671 00000EC9 E36E                    	jcxz .noareafun
  3672                                  .loopareafun:
  3673 00000ECB 263B5D02                	cmp bx, word [es:di + areastrucfunLinear + 2]
  3674 00000ECF 7503                    	jne @F
  3675 00000ED1 263B05                  	cmp ax, word [es:di + areastrucfunLinear]
  3676                                  @@:
  3677 00000ED4 725E                    	jb .nextareafun
  3678                                  
  3679 00000ED6 263B5D06                	cmp bx, word [es:di + areastrucfunLinearEnd + 2]
  3680 00000EDA 7504                    	jne @F
  3681 00000EDC 263B4504                	cmp ax, word [es:di + areastrucfunLinearEnd]
  3682                                  @@:
  3683 00000EE0 7352                    	jae .nextareafun
  3684                                  
  3685 00000EE2 53                      	push bx
  3686 00000EE3 50                      	push ax
  3687 00000EE4 51                      	push cx
  3688 00000EE5 57                      	push di
  3689                                  
  3690 00000EE6 262B05                  	sub ax, word [es:di + areastrucfunLinear]
  3691 00000EE9 261B5D02                	sbb bx, word [es:di + areastrucfunLinear + 2]
  3692 00000EED 7541                    	jnz .nextareafun_pop
  3693                                  
  3694 00000EEF 268B4D0A                	mov cx, word [es:di + areastrucfunListAmount]
  3695 00000EF3 51                      	push cx
  3696 00000EF4 268B7D08                	mov di, word [es:di + areastrucfunListOffset]
  3697 00000EF8 F2AF                    	repne scasw
  3698 00000EFA 59                      	pop cx
  3699 00000EFB 7533                    	jne .nextareafun_pop
  3700 00000EFD 01C9                    	add cx, cx
  3701 00000EFF 4F                      	dec di
  3702 00000F00 4F                      	dec di
  3703 00000F01 01CF                    	add di, cx
  3704 00000F03 6631C9                  _386_PM	xor ecx, ecx
  3705 00000F06 268B0D                  	mov cx, word [es:di]
  3706 00000F09 66                      	_386_PM_o32
  3707 00000F0A 8B36[0000]              	mov si, word [reg_esp]
  3708 00000F0E 66                      	_386_PM_o32
  3709 00000F0F 01CE                    	add si, cx
  3710 00000F11 1E                      	push ds
  3711                                  %if _PM
  3712 00000F12 8B1E[0000]              	mov bx, word [reg_ss]
  3713 00000F16 E8(0000)                	call test_d_b_bit
  3714 00000F19 8EDB                    	mov ds, bx
  3715 00000F1B 7401                    	jz .16
  3716                                  .32:
  3717 00000F1D 67                      	_386_PM_a32
  3718                                  %else
  3719                                  	mov ds, word [reg_ss]
  3720                                  %endif
  3721                                  .16:
  3722 00000F1E AD                      	lodsw
  3723 00000F1F 1F                      	pop ds
  3724                                  .gotfunction:
  3725 00000F20 5F                      	pop di
  3726 00000F21 59                      	pop cx
  3727 00000F22 5B                      	pop bx			; (discard)
  3728 00000F23 5B                      	pop bx
  3729                                  
  3730 00000F24 92                      	xchg dx, ax
  3731 00000F25 8B1E[0000]              	mov bx, word [reg_cs]	; bx:dx = cs:ip
  3732 00000F29 E8BCF9                  	call getlinear_16bit	; dx:ax = linear
  3733 00000F2C 89D3                    	mov bx, dx		; bx:ax = linear
  3734 00000F2E EB09                    	jmp .noareafun
  3735                                  
  3736                                  .nextareafun_pop:
  3737 00000F30 5F                      	pop di
  3738 00000F31 59                      	pop cx
  3739 00000F32 58                      	pop ax
  3740 00000F33 5B                      	pop bx
  3741                                  .nextareafun:
  3742 00000F34 83C70C                  	add di, AREASTRUCFUN_size
  3743 00000F37 E292                    	loop .loopareafun
  3744                                  .noareafun:
  3745 00000F39 5F                      	pop di
  3746                                  
  3747 00000F3A 268B4D20                	mov cx, word [es:di + areastrucSubAmount]
  3748 00000F3E 268B7D22                	mov di, word [es:di + areastrucSubOffset]
  3749 00000F42 E36F                    	jcxz .noareasub
  3750                                  .loopareasub:
  3751 00000F44 263B5D02                	cmp bx, word [es:di + areastrucsubLinear + 2]
  3752 00000F48 7503                    	jne @F
  3753 00000F4A 263B05                  	cmp ax, word [es:di + areastrucsubLinear]
  3754                                  @@:
  3755 00000F4D 725F                    	jb .nextareasub
  3756                                  
  3757 00000F4F 263B5D06                	cmp bx, word [es:di + areastrucsubLinearEnd + 2]
  3758 00000F53 7504                    	jne @F
  3759 00000F55 263B4504                	cmp ax, word [es:di + areastrucsubLinearEnd]
  3760                                  @@:
  3761 00000F59 7353                    	jae .nextareasub
  3762                                  
  3763 00000F5B 53                      	push bx
  3764 00000F5C 50                      	push ax
  3765 00000F5D 51                      	push cx
  3766 00000F5E 57                      	push di
  3767                                  
  3768 00000F5F 262B05                  	sub ax, word [es:di + areastrucsubLinear]
  3769 00000F62 261B5D02                	sbb bx, word [es:di + areastrucsubLinear + 2]
  3770 00000F66 7542                    	jnz .nextareasub_pop
  3771                                  
  3772 00000F68 89C2                    	mov dx, ax		; = ip
  3773 00000F6A 268B7508                	mov si, word [es:di + areastrucsubListOffset]
  3774 00000F6E 268B4D0A                	mov cx, word [es:di + areastrucsubListAmount]
  3775                                  .looparea:
  3776 00000F72 26AD                    	es lodsw
  3777 00000F74 39C2                    	cmp dx, ax
  3778 00000F76 26AD                    	es lodsw
  3779 00000F78 722B                    	jb .nextarea
  3780 00000F7A 39C2                    	cmp dx, ax
  3781 00000F7C 7327                    	jae .nextarea
  3782 00000F7E 26AD                    	es lodsw
  3783 00000F80 89C3                    	mov bx, ax		; es:bx -> area message
  3784 00000F82 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 00000F83 26813F0D0A              	cmp word [es:bx], 13 | (10 << 8)
  3796                                  				; is it with an initial linebreak ?
  3797 00000F88 7509                    	jne @F			; no -->
  3798 00000F8A F606[0000]10            	testopt [serial_flags], sf_use_serial
  3799 00000F8F 7402                    	jz @F			; if not serial -->
  3800 00000F91 42                      	inc dx
  3801 00000F92 42                      	inc dx			; skip the linebreak
  3802                                  @@:
  3803 00000F93 06                      	 push es
  3804 00000F94 1F                      	 pop ds			; => our area hook client's data selector
  3805 00000F95 E8(0000)                	call putsz		; display ds:dx -> ASCIZ message
  3806 00000F98 16                      	 push ss
  3807 00000F99 1F                      	 pop ds			; reset ds
  3808 00000F9A 5F                      	pop di
  3809 00000F9B 59                      	pop cx
  3810 00000F9C 58                      	pop ax
  3811 00000F9D 5B                      	pop bx
  3812                                  
  3813 00000F9E 58                      	pop ax
  3814 00000F9F 5B                      	pop bx
  3815 00000FA0 59                      	pop cx
  3816 00000FA1 5F                      	pop di
  3817 00000FA2 5A                      	pop dx
  3818                                  
  3819 00000FA3 EB1D                    	jmp .end
  3820                                  
  3821                                  .nextarea:
  3822 00000FA5 83C604                  	add si, 4
  3823 00000FA8 E2C8                    	loop .looparea
  3824                                  
  3825                                  .nextareasub_pop:
  3826 00000FAA 5F                      	pop di
  3827 00000FAB 59                      	pop cx
  3828 00000FAC 58                      	pop ax
  3829 00000FAD 5B                      	pop bx
  3830                                  .nextareasub:
  3831 00000FAE 83C70C                  	add di, AREASTRUCSUB_size
  3832 00000FB1 E291                    	loop .loopareasub
  3833                                  .noareasub:
  3834                                  
  3835                                  .next:
  3836 00000FB3 58                      	pop ax
  3837 00000FB4 5B                      	pop bx
  3838 00000FB5 59                      	pop cx
  3839 00000FB6 5F                      	pop di
  3840                                  %if _PM
  3841 00000FB7 5A                      	pop dx
  3842 00000FB8 E8(0000)                	call setes2dx
  3843                                  %else
  3844                                  	pop es
  3845                                  %endif
  3846 00000FBB E202                    	loop .loop_j
  3847 00000FBD EB03                    	jmp .end
  3848                                  
  3849                                  .loop_j:
  3850 00000FBF E9E5FE                  	jmp .loop
  3851                                  
  3852                                  .end:
  3853 00000FC2 66                      	_386_PM_o32		; pop esi
  3854 00000FC3 5E                      	pop si
  3855 00000FC4 5B                      	pop bx
  3856 00000FC5 66                      	_386_PM_o32		; pop ecx
  3857 00000FC6 59                      	pop cx
  3858                                  %endif
  3859 00000FC7 16                      	 push ss
  3860 00000FC8 07                      	 pop es
  3861                                  
  3862                                  .noarea:
  3863 00000FC9 8B16[0000]              	mov dx, word [run_int]
  3864 00000FCD 81FA[0000]              	cmp dx, progtrm
  3865 00000FD1 7515                    	jne .done
  3866                                  
  3867 00000FD3 B8FFFF                  	mov ax, -1
  3868 00000FD6 E8(0000)                	call InDOS
  3869 00000FD9 7504                    	jnz .no_int21_4D
  3870                                  
  3871 00000FDB B44D                    	mov ah, 4Dh
  3872 00000FDD CD21                    	int 21h
  3873                                  .no_int21_4D:
  3874 00000FDF A3[0000]                	mov word [usertermcode], ax
  3875 00000FE2 BF[0000]                	mov di, progexit
  3876 00000FE5 E8(0000)                	call hexword
  3877                                  .done:
  3878 00000FE8 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 00000FEB E830FA                  	call resetmode
  3896                                  %endif
  3897 00000FEE E86AFE                  	call silence_init
  3898 00000FF1 E87CFE                  	call putrunint
  3899 00000FF4 E857FE                  	call silence_exit
  3900                                  %if _CATCHINT19
  3901 00000FF7 81FA[0000]              	cmp dx, int19msg
  3902 00000FFB 7409                    	je .noregs		; if it terminated, skip the registers
  3903                                  %endif
  3904 00000FFD 81FA[0000]              	cmp dx, progtrm
  3905 00001001 7403                    	je .noregs		; if it terminated, skip the registers
  3906 00001003 E80004                  	call dumpregs_extended_silent
  3907                                  .noregs:
  3908 00001006 E8B203                  	call terminate_silent_dump.if_nonnull
  3909 00001009 E8(0000)                	call silence_dump
  3910                                  
  3911 0000100C F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  3912 00001011 7407                    	jz @F
  3913 00001013 F606[0200]20            	testopt [options], gg_unexpected_no_repeat
  3914 00001018 EB05                    	jmp @FF
  3915                                  @@:
  3916 0000101A F606[0200]40            	testopt [options], tp_unexpected_no_repeat
  3917                                  @@:
  3918 0000101F 7406                    	jz @F
  3919 00001021 C706[0000][0000]        	mov word [lastcmd], dmycmd
  3920                                  @@:
  3921                                  
  3922 00001027 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 0000102A F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  3962 0000102F 7403E9A400              	jnz .proceedbreakpoint
  3963                                  
  3964                                  %if _PM
  3965 00001034 E8E7F9                  	call resetmode
  3966                                  %endif
  3967 00001037 31C9                    	xor cx, cx
  3968 00001039 E8(0000)                	call getcseipbyte
  3969 0000103C 3CCD                    	cmp al, 0CDh		; int opcode?
  3970 0000103E 7403E99800              	jne .isstdtrace		; no -->
  3971 00001043 41                      	inc cx
  3972 00001044 E8(0000)                	call getcseipbyte
  3973 00001047 3C03                    	cmp al, 3
  3974 00001049 7503E98D00              	je .isstdtrace		; int 3 opcode -->
  3975 0000104E F606[0000]02            	testopt [options], traceints	; TM=1?
  3976 00001053 7503E9F200              	jz isstdtraceX
  3977                                  %if _IMMASM
  3978 00001058 F606[0300]02            	testopt [internalflags6], dif6_immasm
  3979 0000105D 7403E9E800              	jnz isstdtraceX
  3980                                  %endif
  3981 00001062 3C01                    	cmp al, 1
  3982 00001064 7475                    	je .isstdtrace		; int 1 opcode -->
  3983                                  
  3984                                  		; TM==1, single-step into the INT
  3985 00001066 88C3                    	mov bl, al
  3986                                  %if _PM
  3987 00001068 E8(0000)                	call ispm
  3988 0000106B 745C                    	jz .singlestep_into_interrupt_pm
  3989                                  %endif
  3990 0000106D B700                    	mov bh, 0
  3991 0000106F 1E                      	push ds
  3992 00001070 31C0                    	xor ax, ax
  3993 00001072 8ED8                    	mov ds, ax
  3994 00001074 D1E3                    	shl bx, 1
  3995 00001076 D1E3                    	shl bx, 1
  3996 00001078 C537                    	lds si, [bx]
  3997 0000107A FA                      	cli
  3998 0000107B 8A04                    	mov al, byte [si]
  3999 0000107D FE04                    	inc byte [si]
  4000 0000107F 3804                    	cmp byte [si], al
  4001 00001081 8804                    	mov byte [si], al
  4002 00001083 FB                      	sti
  4003 00001084 8CDB                    	mov bx, ds		; bx:si-> interrupt handler (RM, 16 bit)
  4004 00001086 89D8                    	mov ax, bx
  4005 00001088 1F                      	pop ds
  4006 00001089 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 0000108B 8736[0000]              	xchg si, word [reg_eip]
  4013 0000108F 8706[0000]              	xchg ax, word [reg_cs]	; get cs:ip, set interrupt handler address
  4014 00001093 8B0E[0000]              	mov cx, word [reg_efl]	; get flags
  4015 00001097 1E                      	push ds
  4016 00001098 8B1E[0000]              	mov bx, word [reg_esp]
  4017 0000109C 8E1E[0000]              	mov ds, word [reg_ss]	; ds:bx-> debuggee stack
  4018 000010A0 83EB06                  	sub bx, byte 6		; reserve enough space for flags, cs, ip
  4019 000010A3 46                      	inc si
  4020 000010A4 46                      	inc si			; skip CDh xxh opcode
  4021 000010A5 894F04                  	mov word [bx+4], cx
  4022 000010A8 894702                  	mov word [bx+2], ax
  4023 000010AB 8937                    	mov word [bx+0], si	; save flags, cs, ip on stack
  4024 000010AD 1F                      	pop ds
  4025 000010AE 891E[0000]              	mov word [reg_esp], bx	; update sp
  4026 000010B2 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 000010B7 C706[0000][0000]        	mov word [run_int], int1msg
  4033 000010BD 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 000010C3 B90800                  	mov cx, 8
  4037 000010C6 31C0                    	xor ax, ax		; NC, ZR
  4038 000010C8 C3                      	retn
  4039                                  
  4040                                  %endif
  4041                                  %if _PM
  4042                                  .singlestep_into_interrupt_pm:
  4043 000010C9 B80402                  	mov ax, 0204h
  4044 000010CC CD31                    	int 31h
  4045 000010CE 89CB                    	mov bx, cx
  4046 000010D0 66                      	_386_o32	; mov esi, edx
  4047 000010D1 89D6                    	mov si, dx		; bx:(e)si-> interrupt handler
  4048 000010D3 F6C304                  	test bl, 4		; is it a LDT selector? (NC)
  4049 000010D6 7472                    	jz isstdtraceX		; no -->
  4050                                  %endif
  4051                                  .singlestep_into_interrupt_setbp:
  4052                                  .proceedbreakpoint:
  4053 000010D8 E90F05                  	jmp proceedbreakpoint
  4054                                  
  4055                                  .isstdtrace:
  4056                                  %if _PM
  4057 000010DB E8(0000)                	call ispm
  4058 000010DE 7415                    	jz .notdpmientry	; already in PM -->
  4059 000010E0 A1[0000]                	mov ax, w[reg_eip]	; is this a switch to protected mode ?
  4060 000010E3 3B06[0000]              	cmp ax, w[dpmiwatch+0]
  4061 000010E7 750C                    	jne .notdpmientry
  4062 000010E9 A1[0000]                	mov ax, w[reg_cs]
  4063 000010EC 3B06[0200]              	cmp ax, w[dpmiwatch+2]
  4064 000010F0 7503E9D504              	je isdpmientry		; yes, catch it --> (this means really "go")
  4065                                  .notdpmientry:
  4066                                  %endif
  4067 000010F5 800E[0100]01            	or byte [reg_efl+1], 1	; set single-step mode (cleared when returning into DEBUG)
  4068 000010FA 31C9                    	xor cx, cx
  4069 000010FC E86300                  	call skipprefixes
  4070 000010FF 3C9C                    	cmp al, 9Ch		; opcode "PUSHF"?
  4071 00001101 7527                    	jnz .notpushf
  4072                                  %if _BREAKPOINTS
  4073 00001103 E88605                  	call run_with_bb
  4074 00001106 B400                    	mov ah, 0
  4075 00001108 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 00001109 06                      	push es
  4084                                  %if _PM
  4085 0000110A 8B1E[0000]              	mov bx, word [reg_ss]	; get ss selector into bx
  4086 0000110E 8EC3                    	mov es, bx
  4087 00001110 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 00001113 66                      	_386_PM_o32	; mov ebx, dword [reg_esp]
  4092 00001114 8B1E[0000]              	mov bx, word [reg_esp]	; es:(e)bx-> debuggee's stack
  4093 00001118 7408                    _386_PM	jz .pushf_16
  4094 0000111A 2667806301FE            _386_PM	and byte [es:ebx+1], ~1	; clear TF
  4095 00001120 EB05                    _386_PM	jmp short .pushf_common
  4096                                  .pushf_16:
  4097 00001122 26806701FE              	and byte [es:bx+1], ~1	; clear TF
  4098                                  .pushf_common:
  4099 00001127 07                      	pop es
  4100 00001128 EB06                    	jmp short .checkreturn
  4101                                  .notpushf:
  4102                                  %if _BREAKPOINTS
  4103 0000112A E85F05                  	call run_with_bb
  4104 0000112D B400                    	mov ah, 0
  4105 0000112F 9C                      	pushf
  4106                                  %else
  4107                                  	call run
  4108                                  	xor cx, cx
  4109                                  	xor ax, ax
  4110                                  %endif
  4111                                  .checkreturn:
  4112 00001130 813E[0000][0000]        	cmp word [run_int], int1msg
  4113 00001136 7509                    	jne .nomatch
  4114 00001138 80C908                  	or cl, 8
  4115                                  %if _BREAKPOINTS
  4116 0000113B 9D                      	popf			; CF
  4117 0000113C 7308                    	jnc .ret_NZ_NC
  4118                                  %endif
  4119 0000113E 38C0                    	cmp al, al		; if correct interrupt (ZR, NC)
  4120 00001140 C3                      	retn
  4121                                  
  4122                                  .nomatch:
  4123                                  %if _BREAKPOINTS
  4124 00001141 9D                      	popf			; CF
  4125 00001142 7302                    	jnc .ret_NZ_NC
  4126                                  %endif
  4127 00001144 F9                      	stc
  4128 00001145 C3                      	retn
  4129                                  
  4130                                  %if _BREAKPOINTS
  4131                                  .ret_NZ_NC:
  4132 00001146 80C904                  	or cl, 4		; (NZ, NC)
  4133 00001149 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 0000114A B90200                  	mov cx, 2
  4144 0000114D E84800                  	call iswriteablecseip	; is it ROM ?
  4145 00001150 7289                    	jc traceone.isstdtrace	; is read-only -->
  4146 00001152 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 00001156 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
  4152 00001157 8B36[0000]              	mov si, word [reg_eip]
  4153 0000115B 66                      	_386_PM_o32	; add esi, byte 2
  4154 0000115C 83C602                  	add si, byte 2		; ! do not remove the byte override, else o32 won't work
  4155 0000115F E98804                  	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 00001162 E8(0000)                	call getcseipbyte
  4165 00001165 3C26                    	cmp al, 26h
  4166 00001167 742A                    	je .prefix		; ES
  4167 00001169 3C2E                    	cmp al, 2Eh
  4168 0000116B 7426                    	je .prefix		; CS
  4169 0000116D 3C36                    	cmp al, 36h
  4170 0000116F 7422                    	je .prefix		; SS
  4171 00001171 3C3E                    	cmp al, 3Eh
  4172 00001173 741E                    	je .prefix		; DS
  4173 00001175 3CF0                    	cmp al, 0F0h
  4174 00001177 741A                    	je .prefix		; LOCK
  4175 00001179 3CF3                    	cmp al, 0F3h
  4176 0000117B 7416                    	je .prefix		; REPZ
  4177 0000117D 3CF2                    	cmp al, 0F2h
  4178 0000117F 7412                    	je .prefix		; REPNZ
  4179 00001181 EB14                    	_no386_jmps .noprefix	; no 386, following aren't prefixes (invalid opcodes on 186+) -->
  4180 00001183 3C64                    	cmp al, 64h
  4181 00001185 740C                    	je .prefix		; FS
  4182 00001187 3C65                    	cmp al, 65h
  4183 00001189 7408                    	je .prefix		; GS
  4184 0000118B 3C66                    	cmp al, 66h
  4185 0000118D 7404                    	je .prefix		; o32/o16
  4186 0000118F 3C67                    	cmp al, 67h
  4187 00001191 7504                    	jne .noprefix		; not a32/a16
  4188                                  .prefix:
  4189 00001193 41                      	inc cx
  4190                                  	; jmp short .
  4191 00001194 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 00001196 49                      	dec cx			; back to 07FFFh
  4194                                  .noprefix:
  4195 00001197 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 00001198 E8(0000)                	call getcseipbyte	; get byte at CS:EIP+CX
  4203 0000119B 88C4                    	mov ah, al
  4204 0000119D 34FF                    	xor al, 0FFh
  4205 0000119F E8(0000)                	call setcseipbyte
  4206 000011A2 720E                    	jc .return
  4207 000011A4 E8(0000)                	call getcseipbyte
  4208 000011A7 38C4                    	cmp ah, al     		; is it ROM?
  4209 000011A9 F9                      	stc
  4210 000011AA 7406                    	jz .return
  4211 000011AC 88E0                    	mov al, ah
  4212 000011AE E8(0000)                	call setcseipbyte
  4213 000011B1 F8                      	clc
  4214                                  .return:
  4215 000011B2 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 [B311]                  	dw .code
  4245                                  
  4246                                  	usesection lDEBUG_CODE
  4246          ------------------       note: usesection lDEBUG_CODE
  4247                                  .code:
  4248 000011B3 FB                      	sti
  4249                                  %endif
  4250                                  %if _PM || _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4251                                  debuggerexception:
  4252 000011B4 FC                      	cld
  4253 000011B5 16                      	push ss
  4254 000011B6 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 000011B7 F606[0000]40            	testopt [options6], opt6_debug_exception_early
  4272 000011BC 7402                    	jz @F
  4273 000011BE CC                      	int3
  4274 000011BF 90                      	nop
  4275                                  @@:
  4276                                  %endif
  4277 000011C0 E8(0000)                	call unhack		; sets es to ss
  4278                                  
  4279                                  %if _AREAS
  4280 000011C3 8CCB                    	mov bx, cs
  4281 000011C5 3B1E[0200]              	cmp bx, word [exception_csip + 2]
  4282 000011C9 7532                    	jne .unknownarea
  4283 000011CB A1[0000]                	mov ax, word [exception_csip]
  4284 000011CE BF[A800]                	mov di, areafunctions
  4285 000011D1 B90A00                  	mov cx, areafunctions.amount
  4286 000011D4 F2AF                    	repne scasw
  4287 000011D6 7508                    	jne .unknownfunction
  4288 000011D8 BB[0000]                	mov bx, exception_stack
  4289 000011DB 035D12                  	add bx, word [di - areafunctions - 2 + areafunctions.skip]
  4290 000011DE 8B07                    	mov ax, [bx]
  4291                                  .gotfunction:
  4292                                  
  4293                                  .unknownfunction:
  4294 000011E0 89C2                    	mov dx, ax		; = ip
  4295 000011E2 BE[3000]                	mov si, areas
  4296 000011E5 B90E00                  	mov cx, areas.amount
  4297                                  .looparea:
  4298 000011E8 AD                      	lodsw
  4299 000011E9 39C2                    	cmp dx, ax
  4300 000011EB AD                      	lodsw
  4301 000011EC 720B                    	jb .nextarea
  4302 000011EE 39C2                    	cmp dx, ax
  4303 000011F0 7307                    	jae .nextarea
  4304 000011F2 AD                      	lodsw
  4305 000011F3 92                      	xchg ax, dx
  4306 000011F4 E8(0000)                	call putsz
  4307 000011F7 EB04                    	jmp .donearea
  4308                                  .nextarea:
  4309 000011F9 AD                      	lodsw
  4310 000011FA AD                      	lodsw
  4311 000011FB E2EB                    	loop .looparea
  4312                                  
  4313                                  .donearea:
  4314                                  .unknownarea:
  4315                                  %endif
  4316 000011FD E8C9FD                  	call putrunint.noarea
  4317                                  %if _EXCCSIP
  4318 00001200 BF[0000]                	mov di, exccsip
  4319 00001203 A1[0200]                	mov ax, word [exception_csip + 2]
  4320 00001206 E8(0000)                	call hexword
  4321 00001209 47                      	inc di
  4322 0000120A A1[0000]                	mov ax, word [exception_csip]
  4323 0000120D E8(0000)                	call hexword
  4324                                  
  4325 00001210 BA[0000]                	mov dx, excloc
  4326 00001213 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 00001216 F606[0000]20            	testopt [options6], opt6_debug_exception_late
  4334 0000121B 7401                    	jz @F
  4335 0000121D CC                      	int3
  4336                                  @@:
  4337                                  %endif
  4338 0000121E 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][2C1D][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 000000D0 F9                      	stc
  4426 000000D1 CB                      	retf
  4427 000000D2 00<rep 16h>FFFFFF-      at areastrucNext,	dd -1
  4427 000000EB FF                 
  4428 000000EC FFFFFFFF                at areastrucPrev,	dd -1
  4429 000000F0 0200                    at areastrucSubAmount,	dw areas_sub_amount
  4430 000000F2 [F800]                  at areastrucSubOffset,	dw areas_sub
  4431 000000F4 0100                    at areastrucFunAmount,	dw 1
  4432 000000F6 [1001]                  at areastrucFunOffset,	dw areas_fun
  4433                                  	iend
  4434                                  
  4435                                  areas_sub:
  4436                                  	istruc AREASTRUCSUB
  4437 000000F8 00000000                at areastrucsubLinear,		dd 0
  4438                                  at areastrucsubLinearEnd
  4439                                   %ifn _LINK
  4440                                  				dd ldebug_code_size
  4441                                   %else
  4442 000000FC [0000]                  				dw behind_code wrt lDEBUG_CODE
  4443                                   %endif
  4444 000000FE 00<rep 2h>[3000]        at areastrucsubListOffset,	dw areas
  4445 00000102 0E00                    at areastrucsubListAmount,	dw areas.amount
  4446                                  	iend
  4447                                  %if _DUALCODE && _EXPRDUALCODE
  4448                                  	istruc AREASTRUCSUB
  4449 00000104 00000000                at areastrucsubLinear,		dd 0
  4450                                  at areastrucsubLinearEnd
  4451                                   %ifn _LINK
  4452                                  				dd ldebug_code2_size
  4453                                   %else
  4454 00000108 [0000]                  				dw behind_code2 wrt lDEBUG_CODE2
  4455                                   %endif
  4456 0000010A 00<rep 2h>[A000]        at areastrucsubListOffset,	dw areas2
  4457 0000010E 0100                    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 00000110 00000000                at areastrucfunLinear,		dd 0
  4465                                  at areastrucfunLinearEnd
  4466                                   %ifn _LINK
  4467                                  				dd ldebug_code_size
  4468                                   %else
  4469 00000114 [0000]                  				dw behind_code wrt lDEBUG_CODE
  4470                                   %endif
  4471 00000116 00<rep 2h>[A800]        at areastrucfunListOffset,	dw areafunctions
  4472 0000011A 0A00                    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 00001221 E8(0000)                	call test_d_b_bit
  4486 00001224 7403                    	jz .16
  4487 00001226 80F603                  	xor dh, 1|2		; toggle OSIZE and ASIZE (once)
  4488                                  .16:
  4489 00001229 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 0000122A E8(0000)                	call enable_rh
  4497                                  %endif
  4498 0000122D C706[0000][2A12]        	mov word [lastcmd], pp
  4499 00001233 800E[0100]10            	setopt [internalflags2], dif2_is_pp
  4500 00001238 E80609                  	call parse_pt		; process arguments
  4501                                  
  4502                                  		; Do it <BX:CX=count> times.  First check the type of instruction.
  4503                                  pp1:
  4504 0000123B 53                      	push bx
  4505 0000123C 51                      	push cx			; save bx:cx
  4506                                  %if _PM
  4507 0000123D E8DEF7                  	call resetmode
  4508                                  %endif
  4509 00001240 BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
  4510 00001243 8B1E[0000]              	mov bx, word [reg_cs]
  4511 00001247 66                      	_386_PM_o32	; mov esi, dword [reg_eip]
  4512 00001248 8B36[0000]              	mov si, word [reg_eip]
  4513                                  pp2:
  4514 0000124C E83104                  	call pp16		; get next instruction byte into AL
  4515 0000124F BF[0000]                	mov di, ppbytes
  4516 00001252 B9[0000]                	mov cx, PPLEN
  4517 00001255 A2[0000]                	mov byte [pp_instruction], al
  4518 00001258 F2AE                    	repne scasb
  4519 0000125A 7534                    	jne pp5			; if not one of these -->
  4520                                  %if _LINK_COMPAT
  4521 0000125C 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 00001260 A880                    	test al, PP_PREFIX	; prefix ?
  4526 00001262 740F                    	jz pp3			; no -->
  4527 00001264 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 00001266 FECA                    	dec dl
  4533 00001268 75E2                    	jnz pp2			; if not out of bytes -->
  4534 0000126A BA[0000]                	mov dx, msg.warnprefix
  4535 0000126D E8(0000)                	call putsz
  4536 00001270 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 00001273 E8ABFF                  _386_PM	call pp_fix32bitflags
  4543 00001276 66                      	_386_PM_o32
  4544 00001277 8936[0000]              	mov word [pp_operand], si
  4545 0000127B A840                    	test al, PP_VARSIZ	; different opcode length depends on OSIZE ?
  4546 0000127D 7405                    	jz .ignoreosize		; no -->
  4547 0000127F 80E602                  	and dh, 2
  4548 00001282 00F0                    	add al, dh
  4549                                  .ignoreosize:
  4550 00001284 83E007                  	and ax, PP_SIZ_MASK
  4551 00001287 660FB7C0                _386_PM	movzx eax, ax		; clear high word (in case it counts)
  4552 0000128B 66                      	_386_PM_o32	; add esi, eax
  4553 0000128C 01C6                    	add si, ax
  4554 0000128E EB5C                    	jmp pp10
  4555                                  
  4556                                  
  4557                                  pp5:
  4558 00001290 E88EFF                  _386_PM	call pp_fix32bitflags
  4559 00001293 3CFF                    	cmp al, 0FFh		; FF/2 or FF/3 indirect NEAR or FAR call ?
  4560 00001295 7403E9C700              	jne pp12		; no, just an ordinary instruction -->
  4561 0000129A E8E303                  	call pp16		; get MOD REG R/M byte
  4562 0000129D 24F7                    	and al, ~ (1 << 3)	; clear lowest bit of REG field (/3 to /2)
  4563 0000129F 3410                    	xor al, 2 << 3		; /3 or /2 to /0
  4564 000012A1 A838                    	test al, 7 << 3
  4565 000012A3 7403E9B900              	jnz pp12		; if not FF/2 or FF/3 -->
  4566 000012A8 3CC0                    	cmp al, 0C0h		; mod = 3 ?
  4567 000012AA 7340                    	jae .adjust0		; if just a register -->
  4568 000012AC F6C601                  	test dh, 1
  4569 000012AF 750E                    	jnz .a32		; if 32-bit addressing -->
  4570 000012B1 3C06                    	cmp al, 6		; mod = 0 r/m = 6 would encode bp ?
  4571 000012B3 7433                    	je .adjust2		; if just plain disp16 -->
  4572 000012B5 3C40                    	cmp al, 40h
  4573 000012B7 7233                    	jb .adjust0		; if indirect register -->
  4574 000012B9 3C80                    	cmp al, 80h
  4575 000012BB 722D                    	jb .adjust1		; if disp8[reg(s)]
  4576 000012BD EB29                    	jmp short .adjust2	; it's disp16[reg(s)]
  4577                                  
  4578                                  		; Handle 32-bit addressing (A32 ModR/M referencing memory)
  4579                                  .a32:
  4580 000012BF 3C05                    	cmp al, 5		; mod = 0 and r/m = 5 (would encode ebp) ?
  4581 000012C1 7421                    	je .adjust4		; if just plain disp32 -->
  4582 000012C3 3404                    	xor al, 4		; 4 to 0 (r/m 4 would encode esp)
  4583 000012C5 A807                    	test al, 7		; 0 if r/m would encode esp
  4584 000012C7 7513                    	jnz .a32_nosib		; if no SIB byte -->
  4585 000012C9 86C4                    	xchg al, ah
  4586 000012CB E8B203                  	call pp16
  4587 000012CE 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 000012D0 A8C0                    	test al, 0C0h		; is it mod = 0 ?
  4594 000012D2 7508                    	jnz @F			; no, not a special case -->
  4595 000012D4 80E407                  	and ah, 7
  4596 000012D7 80FC05                  	cmp ah, 5		; is it base = 5 ?
  4597 000012DA 7408                    	je .adjust4		; yes, special case encoding of disp32 -->
  4598                                  @@:
  4599                                  .a32_nosib:
  4600 000012DC 3C40                    	cmp al, 40h
  4601 000012DE 720C                    	jb .adjust0		; if indirect register -->
  4602 000012E0 3C80                    	cmp al, 80h
  4603 000012E2 7206                    	jb .adjust1		; if disp8[reg(s)] -->
  4604                                  				; otherwise, it's disp32[reg(s)]
  4605                                  .adjust4:
  4606 000012E4 66                      	_386_PM_o32	; inc esi
  4607 000012E5 46                      	inc si			; skip an instruction byte
  4608 000012E6 66                      	_386_PM_o32	; inc esi
  4609 000012E7 46                      	inc si			; skip an instruction byte
  4610                                  .adjust2:
  4611 000012E8 66                      	_386_PM_o32	; inc esi
  4612 000012E9 46                      	inc si			; skip an instruction byte
  4613                                  .adjust1:
  4614 000012EA 66                      	_386_PM_o32	; inc esi
  4615 000012EB 46                      	inc si			; skip an instruction byte
  4616                                  .adjust0:
  4617                                  
  4618                                  pp10:
  4619 000012EC 66                      	_386_PM_o32
  4620 000012ED 56                      	push si
  4621                                  
  4622 000012EE 803E[0000]E8            	cmp byte [pp_instruction], 0E8h
  4623 000012F3 7552                    	jne .done
  4624                                  
  4625 000012F5 66                      	_386_PM_o32
  4626 000012F6 8B36[0000]              	mov si, word [pp_operand]
  4627                                  
  4628 000012FA 6631C0                  _386_PM	xor eax, eax
  4629 000012FD E88003                  	call pp16
  4630 00001300 86C4                    	xchg al, ah
  4631 00001302 E87B03                  	call pp16
  4632 00001305 86C4                    	xchg al, ah
  4633 00001307 EB05                    _386_PM	jmp @F
  4634 00001309 F6C602                  	test dh, 2
  4635 0000130C 7539                    	jnz .notcallrel16
  4636                                  @@:
  4637 0000130E F6C602                  _386_PM	test dh, 2
  4638 00001311 7412                    _386_PM	jz @F
  4639                                  
  4640 00001313 66C1C010                _386_PM	rol eax, 16
  4641 00001317 E86603                  _386_PM	call pp16
  4642 0000131A 86C4                    _386_PM	xchg al, ah
  4643 0000131C E86103                  _386_PM	call pp16
  4644 0000131F 86C4                    _386_PM	xchg al, ah
  4645 00001321 66C1C010                _386_PM	rol eax, 16
  4646                                  @@:
  4647 00001325 66                      	_386_PM_o32
  4648 00001326 01C6                    	add si, ax
  4649 00001328 B20F                    	mov dl, 15		; number of bytes to go
  4650                                  .loop:
  4651 0000132A E85303                  	call pp16
  4652 0000132D 3CCB                    	cmp al, 0CBh		; retf ?
  4653 0000132F 7417                    	je .trace
  4654 00001331 3CCA                    	cmp al, 0CAh		; retf imm16 ?
  4655 00001333 7413                    	je .trace
  4656 00001335 3CCF                    	cmp al, 0CFh		; iret ?
  4657 00001337 740F                    	je .trace
  4658 00001339 BF[0000]                	mov di, ppbytes
  4659 0000133C B9[0000]                	mov cx, PPLEN_ONLY_PREFIXES
  4660 0000133F F2AE                    	repne scasb
  4661 00001341 7504                    	jne .done
  4662                                  				; if one of the prefixes
  4663 00001343 FECA                    	dec dl
  4664 00001345 75E3                    	jnz .loop		; if not out of bytes -->
  4665                                  
  4666                                  				; fall through: do not trace
  4667                                  .notcallrel16:
  4668                                  .done:
  4669 00001347 A8                      	db __TEST_IMM8		; (skip stc, NC)
  4670                                  .trace:
  4671 00001348 F9                      	stc			; trace
  4672 00001349 66                      	_386_PM_o32
  4673 0000134A 5E                      	pop si
  4674                                  
  4675 0000134B 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 0000134D E8(0000)                _386_PM	call test_d_b_bit
  4683 00001350 7504                    _386_PM	jnz .32			; full 32-bit offset valid -->
  4684 00001352 660FB7F6                _386_PM	movzx esi, si		; clear high word here
  4685                                  .32:
  4686                                  @@:
  4687 00001356 E89102                  	call proceedbreakpoint	; run until the breakpoint is hit
  4688 00001359 725D                    	jc pp15			; unexpected -->
  4689                                  %if _BREAKPOINTS
  4690 0000135B 7515                    	jnz pp12.bb_hit
  4691                                  %endif
  4692 0000135D 31D2                    	xor dx, dx		; do not skip WHILE
  4693 0000135F EB2F                    	jmp short pp13
  4694                                  
  4695                                  pp12:
  4696 00001361 F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  4697 00001366 75EE                    	jnz @B
  4698                                  
  4699 00001368 E8BFFC                  	call traceone
  4700 0000136B 724B                    	jc pp15
  4701                                  	; jc unexpectedinterrupt
  4702                                  
  4703                                  %if _BREAKPOINTS
  4704 0000136D BA0000                  	mov dx, 0		; do not skip WHILE
  4705 00001370 7416                    	jz @F
  4706                                  
  4707                                  .bb_hit:
  4708 00001372 E833F9                  	call handle_bb_hit_pass_match
  4709 00001375 7204                    	jc .actual_hit
  4710                                  d5	call d5message
  4711                                  d5	asciz "in pp12.bb_hit after non-hit",13,10
  4712 00001377 7422                    	jz pp13.nodump
  4713 00001379 EB15                    	jmp pp13
  4714                                  
  4715                                  
  4716                                  .actual_hit:
  4717                                  %if _PM
  4718 0000137B E8A0F6                  	call resetmode
  4719                                  %endif
  4720 0000137E E82EF0                  	call put_deferred_message_silent
  4721 00001381 E88200                  	call dumpregs_extended_silent
  4722 00001384 59                      	pop cx
  4723 00001385 5B                      	pop bx			; (discard counter)
  4724 00001386 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 00001388 813E[0000][0000]        	cmp word [run_int], int1msg
  4738 0000138E 7528                    	jne pp15		; if some other interrupt (unexpected) -->
  4739                                  
  4740                                  pp13:
  4741 00001390 52                      	push dx
  4742                                  %if _PM
  4743 00001391 E88AF6                  	call resetmode
  4744                                  %endif
  4745                                  		; An expected breakpoint. Dump registers, then loop.
  4746 00001394 E818F0                  	call put_deferred_message_silent
  4747 00001397 E86C00                  	call dumpregs_extended_silent
  4748 0000139A 5A                      	pop dx			; preserve skip WHILE flag
  4749                                  
  4750                                  .nodump:
  4751 0000139B E8B8F8                  	call tt_handle_while
  4752 0000139E 59                      	pop cx
  4753 0000139F 5B                      	pop bx
  4754                                  
  4755 000013A0 83E901                  	sub cx, 1
  4756 000013A3 83DB00                  	sbb bx, 0
  4757                                  
  4758 000013A6 85DB                    	test bx, bx
  4759 000013A8 750B                    	jnz pp14
  4760 000013AA 85C9                    	test cx, cx
  4761 000013AC 7507                    	jnz pp14		; back for more -->
  4762                                  
  4763                                  @@:
  4764                                  %if _PM
  4765 000013AE E86DF6                  	call resetmode
  4766                                  %endif
  4767 000013B1 E8(0000)                	call silence_dump
  4768                                  
  4769 000013B4 C3                      	retn
  4770                                  
  4771                                  %if ($ - pp1 - 1) < 128
  4772                                  pp14: equ pp1
  4773                                  %else
  4774 000013B5 E983FE                  pp14:	jmp pp1
  4775                                  %endif
  4776                                  
  4777                                  pp15:
  4778 000013B8 E930FC                  	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 000013BB F606[0200]10            	testopt [options6], opt6_rh_mode
  5071 000013C0 7507                    	jnz @F
  5072                                  %endif
  5073 000013C2 F606[0300]10            	testopt [internalflags], tt_silent_mode
  5074 000013C7 743C                    	jz terminate_silent_dump.ret
  5075                                  @@:
  5076 000013C9 06                      	push es
  5077 000013CA 57                      	push di
  5078 000013CB 50                      	push ax
  5079 000013CC 8E06[0000]              	mov es, word [auxbuff_segorsel]
  5080 000013D0 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  5081                                  %if _PM
  5082 000013D4 3B3E[0000]              	cmp di, word [auxbuff_switchbuffer_size]
  5083 000013D8 7428                    	je terminate_silent_dump.done
  5084                                  %else
  5085                                  	test di, di
  5086                                  	jz terminate_silent_dump.done
  5087                                  %endif
  5088 000013DA 4F                      	dec di
  5089 000013DB B000                    	mov al, 0
  5090 000013DD AE                      	scasb
  5091 000013DE 7422                    	je terminate_silent_dump.done
  5092 000013E0 EB1B                    	jmp @FF
  5093                                  
  5094                                  terminate_silent_dump:
  5095                                  %if _RH
  5096 000013E2 F606[0200]10            	testopt [options6], opt6_rh_mode
  5097 000013E7 7507                    	jnz @F
  5098                                  %endif
  5099 000013E9 F606[0300]10            	testopt [internalflags], tt_silent_mode
  5100 000013EE 7415                    	jz .ret
  5101                                  @@:
  5102                                  .is_silent:
  5103 000013F0 06                      	push es
  5104 000013F1 57                      	push di
  5105 000013F2 50                      	push ax
  5106 000013F3 8E06[0000]              	mov es, word [auxbuff_segorsel]
  5107 000013F7 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  5108 000013FB B000                    	mov al, 0
  5109                                  @@:
  5110 000013FD AA                      	stosb
  5111 000013FE FF06[0000]              	inc word [auxbuff_behind_last_silent]
  5112                                  				; -> point past the NUL
  5113                                  .done:
  5114 00001402 58                      	pop ax
  5115 00001403 5F                      	pop di
  5116 00001404 07                      	pop es
  5117                                  .ret:
  5118 00001405 C3                      	retn
  5119                                  
  5120                                  
  5121                                  dumpregs_extended_silent:
  5122                                  %if _PM
  5123 00001406 E815F6                  	call resetmode
  5124                                  %endif
  5125 00001409 E84FFA                  	call silence_init
  5126                                  		; Call dumpregs (trimputs, puts, putsline, disasm) with
  5127                                  		;  "silence" flag (writes to auxbuff instead of terminal).
  5128 0000140C 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 0000140F E83CFA                  	call silence_exit
  5135                                  %endif	; !_LOADER
  5136                                  
  5137                                  
  5138                                  handle_serial_flags_ctrl_c: section_of_function
  5139 00001412 1E                      	push ds
  5140 00001413 50                      	push ax
  5141 00001414 16                      	 push ss
  5142 00001415 1F                      	 pop ds
  5143 00001416 F606[0300]40            	testopt [options3], opt3_check_ctrlc_0bh
  5144 0000141B 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 0000141D E8(0000)                	call InDOS
  5149 00001420 7505                    	jnz @F
  5150 00001422 B40B                    	mov ah, 0Bh
  5151                                  	doscall			; allow to break with Ctrl-C
  1490 00001424 E8(0000)            <1>  nearcall _doscall
  5152                                  @@:
  5153                                  @@:
  5154 00001427 F606[0000]02            	testopt [serial_flags], sf_ctrl_c
  5155 0000142C 755B                    	jnz handle_ctrl_c
  5156 0000142E F606[0000]10            	testopt [serial_flags], sf_use_serial
  5157 00001433 7551                    	jnz .ret
  5158 00001435 E8(0000)                	call InDOS_or_BIOS_IO
  5159 00001438 744C                    	jz .ret
  5160 0000143A F606[0300]20            	testopt [options3], opt3_check_ctrlc_keyb
  5161 0000143F 7445                    	jz .ret
  5162                                  
  5163                                  .check_rombios_buffer:
  5164 00001441 53                      	push bx
  5165 00001442 52                      	push dx
  5166 00001443 B84000                  	mov ax, 40h		; dual mode segment/selector
  5167 00001446 50                      	 push ax
  5168 00001447 A1[0000]                	mov ax, word [io_end_buffer]
  5169 0000144A 8B16[0000]              	mov dx, word [io_start_buffer]
  5170 0000144E 1F                      	 pop ds
  5171 0000144F 85C0                    	test ax, ax
  5172 00001451 7503                    	jnz @F
  5173 00001453 A18200                  	mov ax, word [82h]	; end of circular keypress buffer
  5174                                  @@:
  5175 00001456 85D2                    	test dx, dx
  5176 00001458 7504                    	jnz @F
  5177 0000145A 8B168000                	mov dx, word [80h]	; start of circular buffer
  5178                                  @@:
  5179 0000145E 89C3                    	mov bx, ax
  5180 00001460 29D3                    	sub bx, dx		; cmp end, start
  5181 00001462 7620                    	jbe .ret_dx_bx		; invalid -->
  5182 00001464 F6C301                  	test bl, 1		; even amount of bytes ?
  5183 00001467 751B                    	jnz .ret_dx_bx		; invalid -->
  5184 00001469 8B1E1A00                	mov bx, word [1Ah]	; current head of circular buffer
  5185                                  .loop:
  5186 0000146D 3B1E1C00                	cmp bx, word [1Ch]	; equal to current tail ?
  5187 00001471 7411                    	je .ret_dx_bx		; yes, all entries checked -->
  5188 00001473 803F03                  	cmp byte [bx], 3	; is it Ctrl-C ?
  5189 00001476 7411                    	je handle_ctrl_c	; yes, handle -->
  5190 00001478 43                      	inc bx
  5191 00001479 43                      	inc bx			; -> next entry
  5192 0000147A 39C3                    	cmp bx, ax		; at end of buffer ?
  5193 0000147C 72EF                    	jb .loop		; no, loop -->
  5194 0000147E 7704                    	ja .ret_dx_bx		; invalid -->
  5195 00001480 89D3                    	mov bx, dx		; reset to start of buffer
  5196 00001482 EBE9                    	jmp .loop		; then loop -->
  5197                                  
  5198                                  .ret_dx_bx:
  5199 00001484 5A                      	pop dx
  5200 00001485 5B                      	pop bx
  5201                                  
  5202                                  .ret:
  5203 00001486 58                      	pop ax
  5204 00001487 1F                      	pop ds
  5205 00001488 C3                      	retn
  5206                                  
  5207                                  
  5208                                  handle_ctrl_c:
  5209 00001489 16                      	 push ss
  5210 0000148A 1F                      	 pop ds
  5211 0000148B 16                      	 push ss
  5212 0000148C 07                      	 pop es
  5213                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  5214 0000148D C606[0000]00            	mov byte [in_getinput], 0
  5215                                  %endif
  5216 00001492 8026[0000]F9            	clropt [serial_flags], sf_ctrl_c | sf_double_ctrl_c
  5217                                  %if _PM
  5218 00001497 E884F5                  	call resetmode
  5219                                  %endif
  5220                                  %if !_LOADER
  5221 0000149A E81EFF                  	call terminate_silent_dump.if_nonnull
  5222 0000149D E8(0000)                	call silence_dump
  5223                                  %endif
  5224 000014A0 BA[0000]                	mov dx, msg.ctrlc
  5225 000014A3 E8(0000)                	call putsz
  5226                                  
  5227 000014A6 800E[0000]10            	setopt [internalflags3], dif3_input_terminal_override
  5228                                  				; make sure we drain terminal input
  5229                                  @@:
  5230 000014AB E8(0000)                	call getc_if_any	; drain the buffer
  5231 000014AE 75FB                    	jnz @B			; if any was available -->
  5232                                  
  5233 000014B0 8026[0000]EF            	clropt [internalflags3], dif3_input_terminal_override
  5234 000014B5 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 000014B8 B400                    	mov ah, 0
  5256 000014BA F606[0000]40            	testopt [internalflags2], dif2_tpg_proceed_bp_set
  5257 000014BF 745F                    	jz proceed_wp.retn	; (NC)
  5258 000014C1 BF0100                  	mov di, 1
  5259 000014C4 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 000014C6 E820F1                  	call delay_before_bp
  5278                                  %endif
  5279 000014C9 31FF                    	xor di, di
  5280                                  proceed_wp:
  5281                                  	lframe near
  5282 000014CB 5589E5                  	lenter
  5283 000014CE 83F701                  	xor di, 1
  5284                                  	lvar	word, is_write
  5285 000014D1 57                      	 push di
  5286                                  
  5287 000014D2 A1[0000]                	mov ax, word [tpg_proceed_bp]
  5288                                  %if _PM
  5289 000014D5 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 000014D9 E867F5                  	call getsegmented
  5295 000014DC A0[0800]                	mov al, byte [tpg_proceed_bp + BPSIZE - 1]
  5296                                  				; al = byte to restore
  5297 000014DF B402                    	mov ah, 2		; error reason: unreachable
  5298 000014E1 723A                    	jc .return
  5299                                  
  5300 000014E3 F646FE01                	test byte [bp + ?is_write], 1
  5301                                  				; (NC) is it writing ?
  5302 000014E7 7518                    	jnz .write
  5303                                  .restore:
  5304 000014E9 50                      	push ax
  5305 000014EA E8(0000)                	call readmem		; read current byte
  5306 000014ED 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  5307 000014EF B403                    	mov ah, 3		; error reason: overwritten, al = new value
  5308 000014F1 F9                      	stc
  5309 000014F2 7529                    	jne .return_discard	; nope --> (CY)
  5310 000014F4 58                      	pop ax
  5311 000014F5 E8(0000)                	call writemem		; return the byte to its original value
  5312 000014F8 720D                    	jc .next		; failed --> (CY, handled there)
  5313 000014FA C606[0800]CC            	mov byte [tpg_proceed_bp + BPSIZE - 1], 0CCh
  5314                                  				; reset stored point
  5315 000014FF EB06                    	jmp short .next
  5316                                  
  5317                                  .write:
  5318 00001501 E8(0000)                	call writemem
  5319 00001504 A2[0800]                	mov byte [tpg_proceed_bp + BPSIZE - 1], al
  5320                                  				; save the previous byte there
  5321                                  .next:
  5322 00001507 B401                    	mov ah, 1		; (in case of error) error reason: cannot write
  5323 00001509 7212                    	jc .return		; failed to write --> (CY)
  5324 0000150B B400                    	mov ah, 0		; (no error)
  5325                                  
  5326 0000150D 800E[0000]40                    setopt [internalflags2], dif2_tpg_proceed_bp_set
  5327                                  				; set flag in case of successful writing
  5328 00001512 F646FE01                	test byte [bp + ?is_write], 1
  5329                                  				; (NC) is it writing ?
  5330 00001516 7505                    	jnz .return		; yes, leave flag set -->
  5331 00001518 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 0000151D 89EC5D                  	lleave
  5336                                  .retn:
  5337 00001520 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 00001521 E8FAF4                  	call resetmode
  5358                                  %endif
  5359                                  
  5360 00001524 50                      	push ax
  5361 00001525 53                      	push bx
  5362 00001526 51                      	push cx
  5363 00001527 56                      	push si
  5364 00001528 E8(0000)                	call silence_dump	; do away with silent mode
  5365 0000152B 5E                      	pop si
  5366 0000152C 59                      	pop cx
  5367 0000152D 5B                      	pop bx
  5368 0000152E 58                      	pop ax
  5369                                  
  5370 0000152F 800E[0100]08            	setopt [internalflags2], dif2_bp_failure
  5371                                  
  5372                                  	lframe near
  5373                                  	lpar dword, linear
  5374 00001534 5589E5                  	lenter
  5375                                  	lvar word, input_ax
  5376 00001537 50                      	 push ax
  5377                                  
  5378 00001538 BA[0000]                	mov dx, msg.cant_bp_the
  5379 0000153B E8(0000)                	call putsz
  5380 0000153E F6C780                  	test bh, 80h
  5381 00001541 740B                    	jz @F
  5382                                  
  5383 00001543 89C8                    	mov ax, cx
  5384 00001545 40                      	inc ax			; make it 1-based
  5385 00001546 E8CEF2                  	call putordinalbyte
  5386                                  
  5387 00001549 BA[0000]                	mov dx, msg.cant_bp_type_gg
  5388 0000154C EB15                    	jmp .got_type
  5389                                  
  5390                                  @@:
  5391 0000154E F6C740                  	test bh, 40h
  5392 00001551 740D                    	jz @F
  5393                                  
  5394 00001553 89C8                    	mov ax, cx
  5395 00001555 BF[0000]                	mov di, msg.cant_bp_type_permanent.index
  5396 00001558 E8(0000)                	call hexbyte		; (0-based index)
  5397                                  
  5398 0000155B 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 0000155E EB03                    	jmp .got_type
  5409                                  
  5410                                  @@:
  5411 00001560 BA[0000]                	mov dx, msg.cant_bp_type_proceed
  5412                                  
  5413                                  .got_type:
  5414 00001563 E8(0000)                	call putsz
  5415                                  
  5416 00001566 BF[0000]                	mov di, msg.cant_bp_linear.address1
  5417 00001569 8B4606                  	mov ax, word [bp + ?linear + 2]
  5418                                  %ifn _PM
  5419                                  	mov ah, 0
  5420                                  %endif
  5421 0000156C E8(0000)                	call hexword
  5422 0000156F 47                      	inc di
  5423                                  	; mov di, msg.cant_bp_linear.address2
  5424 00001570 8B4604                  	mov ax, word [bp + ?linear]
  5425 00001573 E8(0000)                	call hexword
  5426                                  
  5427 00001576 BA[0000]                	mov dx, msg.cant_bp_linear
  5428 00001579 E8(0000)                	call putsz
  5429                                  
  5430 0000157C BF[0000]                	mov di, msg.cant_bp_restore.value
  5431 0000157F 89D8                    	mov ax, bx
  5432 00001581 E8(0000)                	call hexbyte
  5433                                  
  5434 00001584 BA[0000]                	mov dx, msg.cant_bp_write
  5435 00001587 8B46FE                  	mov ax, word [bp + ?input_ax]
  5436 0000158A F6C480                  	test ah, 80h
  5437 0000158D 7406                    	jz @F
  5438 0000158F 80E47F                  	and ah, ~80h
  5439 00001592 BA[0000]                	mov dx, msg.cant_bp_restore
  5440                                  @@:
  5441 00001595 E8(0000)                	call putsz
  5442                                  
  5443 00001598 BF[0000]                	mov di, msg.cant_bp_reason3.value
  5444 0000159B E8(0000)                	call hexbyte
  5445                                  
  5446 0000159E BA[0000]                	mov dx, msg.cant_bp_reason
  5447 000015A1 E8(0000)                	call putsz
  5448                                  
  5449 000015A4 BA[0000]                	mov dx, msg.cant_bp_reason0
  5450 000015A7 80FC01                  	cmp ah, 1
  5451 000015AA 7215                    	jb @F
  5452 000015AC BA[0000]                	mov dx, msg.cant_bp_reason1
  5453 000015AF 7410                    	je @F
  5454 000015B1 BA[0000]                	mov dx, msg.cant_bp_reason2
  5455 000015B4 80FC03                  	cmp ah, 3
  5456 000015B7 7208                    	jb @F
  5457 000015B9 BA[0000]                	mov dx, msg.cant_bp_reason3
  5458 000015BC 7403                    	je @F
  5459 000015BE BA[0000]                	mov dx, msg.cant_bp_reasonu
  5460                                  @@:
  5461 000015C1 E8(0000)                	call putsz
  5462                                  
  5463 000015C4 89EC5D                  	lleave
  5464 000015C7 C20400                  	lret
  5465                                  
  5466                                  
  5467                                  %if _PM
  5468                                  isdpmientry:
  5469 000015CA F606[0000]02            	testopt [internalflags4], dif4_int_2F_hooked
  5470 000015CF 750A                    	jnz .stdhook
  5471 000015D1 C706[0000][0000]        	mov word [reg_eip], mydpmientry
  5472 000015D7 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 000015DB 8B1E[0000]              	mov bx, word [reg_esp]
  5477 000015DF 1E                      	push ds
  5478 000015E0 8E1E[0000]              	mov ds, word [reg_ss]	; ds:bx-> (16-bit) stack
  5479 000015E4 8B37                    	mov si, word [bx+0]
  5480 000015E6 8B5F02                  	mov bx, word [bx+2]	; get (16-bit) far return address
  5481 000015E9 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 000015EA F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  5519 000015EF 750D                    	jnz @F
  5520                                  
  5521 000015F1 66                      	_386_PM_o32		; mov edx, esi
  5522 000015F2 89F2                    	mov dx, si		; bx:(e)dx = segmented
  5523 000015F4 E8D3F2                  	call getlinear_d_b	; dx:ax = linear
  5524                                  
  5525 000015F7 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 000015FA 8916[0200]              	mov word [tpg_proceed_bp + 2], dx
  5530                                  				; store in point
  5531                                  @@:
  5532 000015FE C606[0800]CC            	mov byte [tpg_proceed_bp + BPSIZE - 1], 0CCh
  5533                                  				; initialise content
  5534 00001603 E8C0FE                  	call proceed_writepoint
  5535                                  		; This call might return modeswitched.
  5536 00001606 7308                    	jnc @F
  5537                                  
  5538 00001608 80E47F                  	and ah, ~80h		; mark error during writing
  5539                                  
  5540 0000160B 31C9                    	xor cx, cx		; cx = 0 in case of branching
  5541 0000160D 51                      	push cx			; put the zero on the stack
  5542                                  
  5543 0000160E EB0E                    	jmp .failure
  5544                                  
  5545                                  @@:
  5546                                  		; The run functions call resetmode.
  5547                                  %if _BREAKPOINTS
  5548 00001610 E87900                  	call run_with_bb
  5549 00001613 89C8                    	mov ax, cx
  5550                                  %else
  5551                                  	call run
  5552                                  	xor ax, ax
  5553                                  %endif
  5554 00001615 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 00001616 E89FFE                  	call proceed_writepoint_restore
  5564                                  		; This call might return modeswitched.
  5565 00001619 7329                    	jnc @F
  5566                                  
  5567 0000161B 80CC80                  	or ah, 80h		; mark error during restoration
  5568                                  
  5569                                  .failure:
  5570                                  		; Here we may be modeswitched.
  5571 0000161E F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  5572                                  				; is it from gg ?
  5573 00001623 7558                    	jnz .return_CY_pop_cx	; (CY) yes, return to gg
  5574                                  		; This branch may be taken while modeswitched.
  5575                                  
  5576                                  %if _PM
  5577 00001625 E8F6F3                  	call resetmode
  5578                                  %endif
  5579                                  
  5580 00001628 E884ED                  	call put_deferred_message_silent
  5581                                  
  5582 0000162B 50                      	push ax
  5583 0000162C E8(0000)                	call silence_dump
  5584 0000162F 58                      	pop ax
  5585                                  
  5586 00001630 FF36[0200]              	 push word [tpg_proceed_bp + 2]
  5587 00001634 FF36[0000]              	 push word [tpg_proceed_bp]
  5588 00001638 8A1E[0800]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
  5589 0000163C B700                    	mov bh, 0
  5590 0000163E E8E0FE                  	call display_breakpoint_failure
  5591                                  		; This function calls resetmode.
  5592 00001641 E9(0000)                	jmp cmd3
  5593                                  
  5594                                  @@:
  5595 00001644 E858F3                  	call get_cseip_of_possible_breakpoint
  5596                                  				; dx:ax = linear address 1 before cs:(e)ip
  5597 00001647 7232                    	jc .return_CY_pop_cx_ax_zero
  5598                                  
  5599 00001649 59                      	pop cx
  5600                                  %if _PM
  5601 0000164A 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 0000164E 7511                    	jne .not_pp
  5608 00001650 3906[0000]              	cmp word [tpg_proceed_bp], ax
  5609 00001654 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 00001656 813E[0000][0000]        	cmp word [run_int], int3msg
  5614 0000165C 7503                    	jne .not_pp		; is unexpected (not returned by interrupt 03h) -->
  5615 0000165E 80C908                  	or cl, 8		; set flag: pp hit
  5616                                  
  5617                                  .not_pp:
  5618 00001661 B400                    	mov ah, 0		; set error to "no error"
  5619                                  
  5620 00001663 E319                    	jcxz .return_CY		; bb hit/pass/nonpass or pp hit ?  if no -->
  5621                                  
  5622 00001665 E869ED                  	call adjust_cseip_after_breakpoint
  5623                                  				; decrement (e)ip to point at the instruction
  5624                                  
  5625 00001668 F6C101                  	test cl, 1		; bb hit ?
  5626 0000166B 750A                    	jnz .return		; yes, return (NC, NZ) -->
  5627                                  
  5628 0000166D F6C108                  	test cl, 8		; proceed point matched ?
  5629 00001670 7506                    	jnz @F			; yes -->
  5630                                  
  5631 00001672 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 00001677 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 00001678 31C0                    	xor ax, ax		; ah = 0 (NC, ZR)
  5642 0000167A C3                      	retn
  5643                                  
  5644                                  		; set ax = 0, pop cx, CY
  5645                                  .return_CY_pop_cx_ax_zero:
  5646 0000167B 31C0                    	xor ax, ax
  5647                                  
  5648                                  		; pop cx, CY (preserve ax)
  5649                                  .return_CY_pop_cx:
  5650 0000167D 59                      	pop cx
  5651                                  .return_CY:
  5652 0000167E F9                      	stc
  5653 0000167F 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 00001680 E8(0000)                	call resetmode_and_test_d_b_bit
  5663                                  %endif
  5664 00001683 1E                      	push ds
  5665 00001684 8EDB                    	mov ds, bx
  5666                                  %if _PM
  5667 00001686 7401                    	jz .16
  5668 00001688 67                      	a32			; use esi for lodsb
  5669                                  .16:
  5670                                  %endif
  5671 00001689 AC                      	lodsb
  5672 0000168A 1F                      	pop ds
  5673 0000168B 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 0000168C F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  5690 00001691 750C                    	jnz .no_bb
  5691                                  
  5692 00001693 F606[0300]C0            	testopt [internalflags], tt_no_bb | tt_no_bb_first
  5693 00001698 740C                    	jz @F
  5694                                  
  5695 0000169A 8026[0300]7F            	clropt [internalflags], tt_no_bb_first
  5696                                  
  5697                                  .no_bb:
  5698 0000169F E87400                  	call run
  5699 000016A2 31C9                    	xor cx, cx
  5700 000016A4 F9                      	stc
  5701 000016A5 C3                      	retn
  5702                                  
  5703                                  @@:
  5704                                  .gg5:
  5705                                  %if _BREAKPOINTS
  5706 000016A6 E870EF                  	call bb_writepoints_init_reset
  5707                                  %endif
  5708                                  
  5709 000016A9 F606[0000]10            	testopt [internalflags2], dif2_gg_first_detected
  5710 000016AE 7436                    	jz .only_run		; easy case, no cseip point detected -->
  5711                                  
  5712                                  
  5713                                  		; Enter special mode: Restore cseip breakpoint content.
  5714 000016B0 800E[0000]02            	setopt [internalflags2], dif2_gg_skip_non_cseip
  5715                                  
  5716 000016B5 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5717 000016B8 89E5                    	mov bp, sp		; -> error info
  5718                                  
  5719 000016BA B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5720                                  				; = index above last one to restore
  5721 000016BD E827F0                  	call bb_restorepoints_and_init_error_info
  5722 000016C0 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 000016C2 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
  5728                                  
  5729                                  		; Enter special mode: Skip cseip breakpoints.
  5730 000016C7 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 000016CC B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5735 000016CF E818F0                  	call bb_restorepoints
  5736                                  
  5737                                  		; Exit special mode: No longer skip cseip breakpoints.
  5738 000016D2 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
  5739                                  
  5740                                  		; The failure that led us here is already noted in the info.
  5741 000016D7 EB1D                    	jmp .bb_exit
  5742                                  
  5743                                  
  5744                                  @@:
  5745                                  		; Success! Now discard the reserved error info.
  5746 000016D9 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5747                                  
  5748                                  		; Exit special mode, do not skip non-cseip breakpoints anymore.
  5749 000016DC 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
  5750                                  
  5751                                  		; Enter special mode: Skip matching/restoring cseip breakpoint.
  5752 000016E1 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
  5753                                  
  5754                                  .only_run:
  5755 000016E6 E82D00                  	call run
  5756                                  .after_run:
  5757                                  
  5758                                  %if _BREAKPOINTS
  5759 000016E9 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5760 000016EC 89E5                    	mov bp, sp
  5761                                  
  5762 000016EE B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5763                                  				; = index above last one to restore
  5764 000016F1 E8F3EF                  	call bb_restorepoints_and_init_error_info
  5765 000016F4 7308                    	jnc @F
  5766                                  
  5767                                  .bb_exit:
  5768 000016F6 B8FFFF                  	mov ax, -1
  5769 000016F9 50                      	push ax			; (unused: ax error info)
  5770 000016FA 50                      	push ax			; cx error point index, -1 = invalid
  5771                                  
  5772 000016FB E938EF                  	jmp bb_restorepoints_exit
  5773                                  
  5774                                  
  5775                                  @@:
  5776 000016FE 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5777                                  
  5778 00001701 E8E8EC                  	call bb_check_hit
  5779 00001704 89C1                    	mov cx, ax
  5780 00001706 9C                      	pushf
  5781                                  		; Clear all special modes. Stop specialcasing cseip breakpoint.
  5782                                  		;
  5783                                  		; This resets all the special flags for subsequent calls.
  5784 00001707 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  5787 0000170C 9D                      	popf			; CF
  5788 0000170D 7302                    	jnc @F
  5789                                  
  5790 0000170F F9                      	stc
  5791                                  				; cx = flags as returned by bb_check_hit
  5792 00001710 C3                      	retn
  5793                                  
  5794                                  @@:
  5795 00001711 E8BDEC                  	call adjust_cseip_after_breakpoint
  5796                                  				; re-execute (restored) opcode one byte in front of this
  5797 00001714 F8                      	clc			; (NC)
  5798                                  				; cx = flags as returned by bb_check_hit
  5799 00001715 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 00001716 16                      	 push ss
  5822 00001717 07                      	 pop es
  5823                                  %if _PM
  5824 00001718 E803F3                  	call resetmode
  5825 0000171B E8DC02                  	call remember_mode
  5826                                  %endif
  5827                                  %if _DELAY_BEFORE_BP
  5828 0000171E 8026[0200]7F            	clropt [internalflags3], dif3_delayed
  5829                                  %endif
  5830                                  %if !_LOADER
  5831 00001723 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 00001729 E8E105                  	call seteq			; set CS:IP to '=' address
  5836                                  %endif
  5837                                  
  5838                                  %if _VXCHG
  5839 0000172C B000                    	mov al, 0			; restore debuggee screen
  5840 0000172E E8(0000)                	call swapscreen
  5841                                  %endif
  5842                                  
  5843                                  %if _ALTVID
  5844 00001731 E8A201                  	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 00001734 8E06[0000]              	mov es, word [reg_ds]
  5865 00001738 8E06[0000]              	mov es, word [reg_ss]
  5866 0000173C 8E06[0000]              _386	mov es, word [reg_fs]
  5867 00001740 8E06[0000]              _386	mov es, word [reg_gs]
  5868                                  %endif
  5869 00001744 8E06[0000]              	mov es, word [reg_es]		; last one: actual es value
  5870                                  
  5871                                  %if !_LOADER
  5872 00001748 8B1E[0000]              	mov bx, word [pspdbe]
  5873 0000174C E8(0000)                	call setpsp			; set debuggee's PSP
  5874 0000174F 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 00001752 A9                      	db __TEST_IMM16
  5881 00001753 8D00                    	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 00001755 51                      	push cx
  5892 00001756 56                      	push si
  5893 00001757 50                      	push ax
  5894 00001758 52                      	push dx
  5895 00001759 06                      	push es
  5896 0000175A 53                      	push bx
  5897 0000175B 55                      	push bp
  5898 0000175C 57                      	push di
  5899                                  
  5900                                  %if _PM
  5901 0000175D E8(0000)                	call ispm
  5902 00001760 7414                    	jz @F			; in PM -->
  5903 00001762 F606[0200]04            	testopt [internalflags], canswitchmode
  5904 00001767 7410                    	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 00001769 800E[0200]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  5909 0000176E B000                    	mov al, 0
  5910 00001770 E886F2                  	call sr_state		; save state
  5911 00001773 E849F2                  	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 00001776 E80B03                  	call pm_set_handlers
  5916                                  		; ! this calls resetmode
  5917                                  @@:
  5918                                  %endif
  5919                                  
  5920                                  %if _CATCHINT06 && _DETECT95LX
  5921 00001779 8B0E[0000]              	mov cx, word [inttab_number_variable]
  5922                                  %else
  5923                                  	mov cx, inttab_number
  5924                                  %endif
  5925 0000177D E35B                    	jcxz .intend
  5926 0000177F BE[0000]                	mov si, inttab
  5927                                  .intloop:
  5928 00001782 AC                      	lodsb
  5929 00001783 92                      	xchg ax, dx
  5930 00001784 AD                      	lodsw				; get address
  5931 00001785 92                      	xchg ax, dx
  5932                                  %if _DEBUGUPDATESAVE
  5933 00001786 89D7                    	mov di, dx			; -> IISP header
  5934                                  %endif
  5935                                  
  5936 00001788 E8(0000)                	call InDOS
  5937 0000178B 7432                    	jz .int21_25
  5938                                  
  5939 0000178D 31DB                    	xor bx, bx
  5940                                  %if _PM
  5941 0000178F E8(0000)                	call ispm
  5942 00001792 7507                    	jnz @F
  5943 00001794 52                      	push dx
  5944 00001795 89DA                    	mov dx, bx			; set segment to access (= 0)
  5945 00001797 E8(0000)                	call setrmsegm			; get bx = selector configured to this
  5946 0000179A 5A                      	pop dx
  5947                                  @@:
  5948                                  %endif
  5949 0000179B 8EC3                    	mov es, bx			; => 86 Mode IVT (segment or selector)
  5950                                  %if _PM
  5951 0000179D 31DB                    	xor bx, bx			; bh = 0
  5952                                  %endif
  5953 0000179F 88C3                    	mov bl, al
  5954 000017A1 01DB                    	add bx, bx
  5955 000017A3 01DB                    	add bx, bx
  5956                                  
  5957                                  %if _DEBUGUPDATESAVE
  5958 000017A5 26FF7702                	push word [ es:bx + 2 ]
  5959 000017A9 26FF37                  	push word [ es:bx ]		; get vector
  5960 000017AC 8F4502                  	pop word [ di + ieNext ]
  5961 000017AF 8F4504                  	pop word [ di + ieNext + 2]
  5962                                  %endif
  5963                                  
  5964 000017B2 268917                  	mov word [ es:bx ], dx
  5965                                  %if _PM
  5966 000017B5 FF36[0000]              	push word [ pspdbg ]		; => lDEBUG_DATA_ENTRY (86 Mode seg)
  5967 000017B9 268F4702                	pop word [ es:bx + 2 ]
  5968                                  %else
  5969                                  	mov word [ es:bx + 2 ], ds	; => lDEBUG_DATA_ENTRY
  5970                                  %endif
  5971 000017BD EB19                    	jmp short .intset
  5972                                  
  5973                                  .int21_25:
  5974                                  
  5975                                  %if _PM
  5976                                   %if _DEBUGUPDATESAVE
  5977 000017BF B435                    	mov ah, 35h			; get interrupt vector
  5978 000017C1 FF36[0000]              	 push word [pspdbg]		; => lDEBUG_DATA_ENTRY
  5979 000017C5 E8(0000)                	dual2call _doscall_return_es_parameter_es_ds
  5980 000017C8 895D02                  	mov word [ di + ieNext ], bx
  5981 000017CB 8F4504                  	 pop word [ di + ieNext + 2 ]
  5982                                   %endif
  5983 000017CE B425                    	mov ah, 25h			; set interrupt vector
  5984 000017D0 FF36[0000]              	push word [pspdbg]		; => lDEBUG_DATA_ENTRY
  5985 000017D4 E8(0000)                	dual2call _doscall_return_es_parameter_es_ds
  5986 000017D7 58                      	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 000017D8 E2A8                    	loop .intloop
  5999                                  
  6000                                  .intend:
  6001 000017DA 5F                      	pop di
  6002 000017DB 5D                      	pop bp
  6003 000017DC 5B                      	pop bx
  6004 000017DD 07                      	pop es
  6005 000017DE 5A                      	pop dx
  6006 000017DF 58                      	pop ax
  6007 000017E0 5E                      	pop si
  6008 000017E1 59                      	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 000017E2 E8(0000)                	call ispm
  6019 000017E5 7505                    	jnz @F
  6020 000017E7 FF36[0000]              	push word [cssel]
  6021 000017EB A8                      	db __TEST_IMM8			; (skip push)
  6022                                  @@:
  6023                                   %endif
  6024 000017EC 16                      	push ss
  6025 000017ED B8[1C01]                	mov ax, .entry
  6026 000017F0 50                      	push ax
  6027 000017F1 CB                      	retf
  6028                                  
  6029                                  	usesection lDEBUG_DATA_ENTRY
  6029          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6030                                  .entry:
  6031                                  %endif
  6032 0000011C 2B26[0000]              	sub sp, word [run_sp_reserve]
  6033 00000120 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 00000124 A1[0000]                	mov ax, word [pspdbg]
  6052                                   %else
  6053                                  	mov ax, ss
  6054                                   %endif
  6055 00000127 3B063000                	cmp ax, word [SPSAV + 2]
  6056 0000012B 7508                    	jne @F
  6057                                  %endif
  6058 0000012D 2B26[0000]              	sub sp, word [spadjust]
  6059 00000131 89262E00                	mov word [SPSAV], sp
  6060                                  @@:
  6061                                  %endif
  6062 00000135 FA                      	cli
  6063                                  
  6064 00000136 BC[0000]                	mov sp, regs
  6065                                  %ifn _ONLY386
  6066 00000139 EB11                    	_386_jmps .386			; -->
  6067 0000013B 58                      	pop ax
  6068 0000013C 58                      	pop ax				; discard all high words
  6069 0000013D 5B                      	pop bx
  6070 0000013E 58                      	pop ax
  6071 0000013F 59                      	pop cx
  6072 00000140 58                      	pop ax
  6073 00000141 5A                      	pop dx
  6074 00000142 58                      	pop ax
  6075 00000143 58                      	pop ax				; we'll get esp later
  6076 00000144 58                      	pop ax
  6077 00000145 5D                      	pop bp
  6078 00000146 58                      	pop ax
  6079 00000147 5E                      	pop si
  6080 00000148 58                      	pop ax
  6081 00000149 5F                      	pop di
  6082                                  		; ds, ss, cs loaded later
  6083                                  		; es already loaded
  6084                                  %endif
  6085                                  %ifn _ONLYNON386
  6086                                   %ifn _ONLY386
  6087 0000014A EB18                    	jmp short .common
  6088                                   %endif
  6089                                  
  6090                                  .386:
  6091                                  [cpu 386]
  6092 0000014C 6658                    	pop eax
  6093 0000014E 665B                    	pop ebx
  6094 00000150 6659                    	pop ecx
  6095 00000152 665A                    	pop edx
  6096 00000154 58                      	pop ax
  6097 00000155 58                      	pop ax				; we'll get esp later
  6098 00000156 665D                    	pop ebp
  6099 00000158 665E                    	pop esi
  6100 0000015A 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 0000015C 83C410                  	add sp, byte 8 * 2
  6110 0000015F 0FA1                    	pop fs
  6111 00000161 58                      	pop ax
  6112 00000162 0FA9                    	pop gs
  6113                                  __CPU__
  6114                                  .common:
  6115                                  %endif
  6116 00000164 A1[0000]                	mov ax, word [reg_eax]		; restore ax (used to discard words)
  6117 00000167 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 0000016B 66                      	o32			; mov esp, dword [reg_esp]
  6123 0000016C 8B26[0000]              	mov sp, word [reg_esp]		; restore program stack
  6124                                  %endif
  6125 00000170 C606[0000]00            	mov byte [bInDbg], 0
  6126                                  
  6127 00000175 90<rep 3h>              	align 4, nop
  6128                                  patcharea_run:
  6129 00000178 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 00000198 66                      	_386_o32		; push dword [reg_efl]
  6139 00000199 FF36[0000]              	push word [reg_efl]
  6140 0000019D 66                      	_386_o32		; push dword [reg_cs]	; high word is zero
  6141 0000019E FF36[0000]              	push word [reg_cs]
  6142 000001A2 66                      	_386_o32		; push dword [reg_eip]
  6143 000001A3 FF36[0000]              	push word [reg_eip]
  6144 000001A7 F606[0100]02            	test byte [reg_efl+1], 2	; IF set?
  6145 000001AC 8E1E[0000]              	mov ds, word [reg_ds]		; restore ds
  6146 000001B0 7401                    	jz .di
  6147 000001B2 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 000001B3 66                      	o32			; iretd
  6154 000001B4 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 000001B5 CBEB10FFFFFFFF4B42-     iispentry intr8, 0
  6205 000001BE 00EBF400<rep 7h>   
  6206                                  intr8_original: equ intr8.next
  6207 000001C8 9C                      	pushf
  6208 000001C9 2EFF1E[B801]            	call far [cs:intr8_original]
  6209 000001CE 9C                      	pushf
  6210 000001CF 53                      	push bx
  6211 000001D0 1E                      	push ds
  6212                                  
  6213 000001D1 0E                      	 push cs
  6214 000001D2 1F                      	 pop ds
  6215                                  
  6216 000001D3 803E[0000]00            	cmp byte [bInDbg], 0		; in debugger ?
  6217 000001D8 7559                    	jne .reset			; yes -->
  6218                                  
  6219 000001DA F606[0000]04            	testopt [serial_flags], sf_double_ctrl_c
  6220 000001DF 7408                    	jz @F
  6221                                  
  6222 000001E1 C706[0000][0000]        	mov word [run_int], runint_ctrlc_msg
  6223 000001E7 EB44                    	jmp @FF
  6224                                  
  6225                                  @@:
  6226 000001E9 BB4000                  	mov bx, 40h
  6227 000001EC 8EDB                    	mov ds, bx
  6228 000001EE F606170004              	test byte [17h], 4		; CTRL currently pressed ?
  6229 000001F3 0E                      	 push cs
  6230 000001F4 1F                      	 pop ds
  6231 000001F5 743C                    	jz .reset			; no -->
  6232                                  
  6233 000001F7 8B1E[0000]              	mov bx, word [intr8_limit]
  6234 000001FB 85DB                    	test bx, bx			; enabled ?
  6235 000001FD 7439                    	jz .return			; no -->
  6236 000001FF FF06[0000]              	inc word [intr8_counter]
  6237 00000203 391E[0000]              	cmp word [intr8_counter], bx	; default is ca 5 seconds
  6238 00000207 722F                    	jb .return
  6239                                  
  6240 00000209 C706[0000][0000]        	mov word [run_int], int8msg
  6241 0000020F F606[0100]80            	testopt [options], int8_disable_serial
  6242 00000214 7417                    	jz @F
  6243 00000216 F606[0000]10            	testopt [serial_flags], sf_use_serial
  6244 0000021B 7410                    	jz @F
  6245                                  
  6246                                  		; Immediately disable use of serial I/O.
  6247 0000021D 8026[0000]EF            	clropt [serial_flags], sf_use_serial
  6248 00000222 8026[0100]BF            	clropt [options], enable_serial
  6249 00000227 C706[0000][0000]        	mov word [run_int], int8_kbd_msg
  6250                                  
  6251                                  @@:
  6252 0000022D 1F                      	pop ds
  6253 0000022E 5B                      	pop bx
  6254 0000022F 9D                      	popf				; (in 86 Mode)
  6255 00000230 E98D01                  	jmp intrtn
  6256                                  
  6257                                  .reset:
  6258 00000233 8326[0000]00            	and word [intr8_counter], 0
  6259                                  .return:
  6260 00000238 1F                      	pop ds
  6261 00000239 5B                      	pop bx
  6262 0000023A 9D                      	popf				; (in 86 Mode)
  6263 0000023B CF                      	iret
  6264                                  %endif
  6265                                  
  6266                                  
  6267                                  %if !_LOADER
  6268                                  		; Interrupt 22h (program termination) handler.
  6269                                  int22:
  6270 0000023C FA                      	cli
  6271                                  .cleartraceflag:
  6272 0000023D 0E                      	push cs
  6273 0000023E 1F                      	pop ds
  6274 0000023F 0E                      	push cs
  6275 00000240 17                      	pop ss
  6276 00000241 8B26[0000]              	mov sp, word [run_sp]	; restore running stack
  6277 00000245 0326[0000]              	add sp, word [run_sp_reserve]
  6278 00000249 C706[0000][0000]        	mov word [run_int], progtrm	; set interrupt message
  6279 0000024F C706[0000][0000]        	mov word [lastcmd], dmycmd	; disable T/P/G auto-repeat
  6280                                  %if _PM
  6281 00000255 C606[0000]00            	mov byte [pm_2_86m_0], 0
  6282 0000025A 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 0000025F E91D02                  	jmp intrtn1_entry
  6291                                  %endif
  6292                                  %endif	; !_LOADER
  6293                                  
  6294                                  sharedentry1.hwreset:
  6295 00000262 CB                      	retf
  6296                                  
  6297                                  
  6298                                  %if !_LOADER
  6299 00000263 90                      	align 2
  6300 00000264 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 00000266 EB10FFFFFFFF4B4200-     iispentry intr1, 0, sharedentry1
  6305 0000026F EBF100<rep 7h>     
  6306                                  	lframe int
  6307 00000278 5589E5                  	lenter
  6308 0000027B 50                      	push ax
  6309                                  
  6310                                  %ifn _PASSTF
  6311 0000027C 806607FE                	clropt [bp + ?frame_fl], 100h	; clear TF (always)
  6312                                  %endif
  6313                                  
  6314 00000280 8CC8                    	mov ax, cs
  6315 00000282 394604                  	cmp word [bp + ?frame_cs], ax	; entry segment ?
  6316 00000285 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 00000287 817E02[B802]            	cmp word [bp + ?frame_ip], intr0
  6326 0000028C 741A                    	je .if_ZR			; that one --> (ZR)
  6327 0000028E 817E02[D402]            	cmp word [bp + ?frame_ip], intr3
  6328 00000293 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 00000295 817E02[0000]            	cmp word [bp + ?frame_ip], getline_extra_int22.cleartraceflag
  6338 0000029A 740C                    	je .if_ZR			; that one --> (ZR)
  6339                                  %endif
  6340 0000029C 817E02[3D02]            	cmp word [bp + ?frame_ip], int22.cleartraceflag
  6341 000002A1 7405                    	je .if_ZR			; that one --> (ZR)
  6342 000002A3 817E02[0000]            	cmp word [bp + ?frame_ip], debug22.cleartraceflag
  6343                                  .if_ZR:
  6344 000002A8 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 000002A9 5D                      	lleave , optimiserestoresp	; restore bp (common before branch)
  6356 000002AA 7501                    	jnz @F				; handle trace entry -->
  6357 000002AC CF                      	iret				; continue run if matched
  6358                                  
  6359                                  @@:
  6360                                  %endif
  6361                                  
  6362 000002AD 2EC706[0000][0000]      	mov word [cs:run_int], int1msg	; remember interrupt type
  6363 000002B4 E90901                  	jmp intrtn			; jump to register saving routine
  6364                                  
  6365                                  
  6366                                  		; Interrupt 00h (divide error) handler.
  6367 000002B7 90EB10FFFFFFFF4B42-     iispentry intr0, 0, sharedentry1
  6367 000002C0 00EB9F00<rep 7h>   
  6368 000002CA 2EC706[0000][0000]      	mov word [cs:run_int], int0msg	; remember interrupt type
  6369 000002D1 E9EC00                  	jmp intrtn			; jump to register saving routine
  6370                                  
  6371                                  
  6372                                  
  6373                                  		; Interrupt 03h (breakpoint interrupt) handler.
  6374 000002D4 EB10FFFFFFFF4B4200-     iispentry intr3, 0, sharedentry1
  6374 000002DD EB8300<rep 7h>     
  6375 000002E6 2EC706[0000][0000]      	mov word [cs:run_int], int3msg	; remember interrupt type
  6376                                  %if _CATCHINT06
  6377 000002ED E9D000                  	jmp intrtn			; jump to register saving routine
  6378                                  
  6379                                  
  6380                                  		; Interrupt 06h (invalid opcode) handler.
  6381 000002F0 EB10FFFFFFFF4B4200-     iispentry intr6, 0, sharedentry2
  6381 000002F9 EB1100<rep 7h>     
  6382 00000302 2EC706[0000][0000]      	mov word [cs:run_int], int6msg	; remember interrupt type
  6383                                  %endif
  6384 00000309 E9B400                  	jmp intrtn			; jump to register saving routine
  6385                                  %endif	; !_LOADER
  6386                                  
  6387                                  
  6388                                  sharedentry2.hwreset:
  6389 0000030C 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 0000030D 90EB10FFFFFFFF4B42-     iispentry intr0C, 0, sharedentry2
  6403 00000316 00EBF300<rep 7h>   
  6404                                   %if _MCLOPT
  6405                                  	cmp byte [cs:master_pic_base], 20h
  6406                                  	jae @F
  6407                                   %endif
  6408 00000320 50                      	push ax
  6409 00000321 B00B                    	mov al, 0Bh			; request In-Service Register (ISR)
  6410 00000323 E620                    	out 20h, al			; from primary PIC
  6411 00000325 E420                    	in al, 20h			; read the ISR
  6412 00000327 A810                    	test al, 1_0000b		; IRQ #4 occurred ?
  6413 00000329 58                      	pop ax
  6414 0000032A 7515                    	jnz .notours			; yes, (likely) not a stack fault -->
  6415                                  @@:
  6416 0000032C 2EC706[0000][0000]      	mov word [cs:run_int], int0Cmsg	; remember interrupt type
  6417 00000333 2E803E[0000]00          	cmp byte [cs:bInDbg], 0
  6418 00000339 7403E9C4FC              	jne r86m_debugger_exception
  6419 0000033E E97F00                  	jmp intrtn			; jump to register saving routine
  6420                                  
  6421                                  .notours:
  6422 00000341 2EFF2E[1003]            	jmp far [cs:.next]
  6423                                  %endif
  6424                                  %if _CATCHINT0D
  6425                                  
  6426                                  
  6427                                  		; Interrupt 0Dh (general protection fault in R86M, or IRQ) handler.
  6428 00000346 EB10FFFFFFFF4B4200-     iispentry intr0D, 0, sharedentry2
  6428 0000034F EBBB00<rep 7h>     
  6429                                   %if _MCLOPT
  6430                                  	cmp byte [cs:master_pic_base], 20h
  6431                                  	jae @F
  6432                                   %endif
  6433 00000358 50                      	push ax
  6434 00000359 B00B                    	mov al, 0Bh			; request In-Service Register (ISR)
  6435 0000035B E620                    	out 20h, al			; from primary PIC
  6436 0000035D E420                    	in al, 20h			; read the ISR
  6437 0000035F A820                    	test al, 10_0000b		; IRQ #5 occurred ?
  6438 00000361 58                      	pop ax
  6439 00000362 7514                    	jnz .notours			; yes, (likely) not a GPF -->
  6440                                  @@:
  6441 00000364 2EC706[0000][0000]      	mov word [cs:run_int], int0Dmsg	; remember interrupt type
  6442 0000036B 2E803E[0000]00          	cmp byte [cs:bInDbg], 0
  6443 00000371 7403E98CFC              	jne r86m_debugger_exception
  6444 00000376 EB48                    	jmp intrtn			; jump to register saving routine
  6445                                  
  6446                                  .notours:
  6447 00000378 2EFF2E[4803]            	jmp far [cs:.next]
  6448                                  %endif
  6449                                  %if _CATCHINT18
  6450                                  		; Interrupt 18h (diskless boot hook) handler.
  6451 0000037D 90EB10FFFFFFFF4B42-     iispentry intr18, 0, sharedentry3
  6451 00000386 00EB7900<rep 7h>   
  6452 00000390 2EC706[0000][0000]      	mov word [cs:run_int], int18msg	; remember interrupt type
  6453                                  %endif
  6454                                  %if _CATCHINT19
  6455 00000397 EB27                    	jmp intrtn			; jump to register saving routine
  6456                                  
  6457                                  
  6458                                  		; Interrupt 19h (boot load) handler.
  6459 00000399 90EB10FFFFFFFF4B42-     iispentry intr19, 0, sharedentry3
  6459 000003A2 00EB5D00<rep 7h>   
  6460 000003AC 2EC706[0000][0000]      	mov word [cs:run_int], int19msg	; remember interrupt type
  6461 000003B3 2EC706[0000][0000]      	mov word [cs:lastcmd], dmycmd	; disable T/P/G auto-repeat
  6462 000003BA 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 000003C0 FA                      	cli				; just in case
  6471 000003C1 2E8F06[0000]            	pop word [cs:reg_eip]		; recover things from stack
  6472 000003C6 2E8F06[0000]            	pop word [cs:reg_cs]
  6473 000003CB 2E8F06[0000]            	pop word [cs:reg_efl]
  6474 000003D0 2E8C1E[0000]            	mov word [cs:reg_ds], ds	; ! word-aligned (AC flag)
  6475 000003D5 2EA3[0000]              	mov word [cs:reg_eax], ax	; ! word-aligned (AC flag)
  6476 000003D9 8CC8                    	mov ax, cs
  6477 000003DB 8ED8                    	mov ds, ax			; => lDEBUG_DATA_ENTRY
  6478                                  
  6479 000003DD 90<rep 3h>              	align 4, nop
  6480                                  patcharea_intrtn:
  6481 000003E0 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 00000400 EB01                    	jmp intrtn_entry
  6494                                  %endif
  6495                                  
  6496                                  sharedentry3.hwreset:
  6497 00000402 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 00000403 C606[0000]00            	mov byte [pm_2_86m_0], 0
  6512 00000408 8026[0100]F7            	clropt [internalflags], protectedmode	; reset PM flag
  6513                                  .from_installdpmi:
  6514                                  %endif
  6515 0000040D 8C16[0000]              	mov word [reg_ss], ss	; save stack position
  6516 00000411 8326[0200]00            _386	and word [reg_eip+2], byte 0	; we're from real mode
  6517 00000416 66                      	_386_o32		; mov dword [reg_esp], esp
  6518 00000417 8926[0000]              	mov word [reg_esp], sp
  6519 0000041B 8ED0                    	mov ss, ax		; mov ss, cs	; (don't use the stack here)
  6520                                  
  6521                                  %if _PM
  6522 0000041D 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 0000041F 368C1E[0000]            	mov word [ss:reg_ds], ds	; ! word-aligned (AC flag)
  6530 00000424 36A3[0000]              	mov word [ss:reg_eax], ax	; ! word-aligned (AC flag)
  6531 00000428 8CD0                    	mov ax, ss
  6532 0000042A 8ED8                    	mov ds, ax		; mov ds, ss
  6533                                  @@:
  6534                                  %endif
  6535 0000042C B80200                  	mov ax, 2
  6536                                  %ifn _ONLY386
  6537 0000042F EB1A                    	_386_jmps .386			; -->
  6538 00000431 BC[0200]                	mov sp, reg_es+2
  6539 00000434 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 00000435 83EC06                  	sub sp, byte 3*2
  6544 00000438 57                      	push di
  6545 00000439 29C4                    	sub sp, ax
  6546 0000043B 56                      	push si
  6547 0000043C 29C4                    	sub sp, ax
  6548 0000043E 55                      	push bp
  6549                                  	; sub sp, ax
  6550                                  	; sub sp, ax			; sp already saved
  6551                                  	; sub sp, ax
  6552 0000043F 83EC06                  	sub sp, byte 3*2
  6553 00000442 52                      	push dx
  6554 00000443 29C4                    	sub sp, ax
  6555 00000445 51                      	push cx
  6556 00000446 29C4                    	sub sp, ax
  6557 00000448 53                      	push bx
  6558                                  %endif
  6559                                  %ifn _ONLYNON386
  6560                                   %ifn _ONLY386
  6561 00000449 EB34                    	jmp short .common
  6562                                   %endif
  6563                                  
  6564                                  .386:
  6565                                  [cpu 386]
  6566 0000044B 66BC[02000000]          	mov esp, reg_gs+2
  6567 00000451 0FA8                    	push gs
  6568 00000453 29C4                    	sub sp, ax			; don't overwrite high words of segments
  6569 00000455 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 00000457 83EC0A                  	sub sp, byte 5*2
  6576 0000045A 06                      	push es
  6577                                  	; sub sp, ax
  6578                                  	; sub sp, ax			; ds already saved
  6579 0000045B 83EC04                  	sub sp, byte 2*2
  6580 0000045E 6657                    	push edi
  6581 00000460 6656                    	push esi
  6582 00000462 6655                    	push ebp
  6583                                  	; sub sp, ax
  6584                                  	; sub sp, ax			; sp already saved
  6585 00000464 83EC04                  	sub sp, byte 2*2
  6586 00000467 6652                    	push edx
  6587 00000469 6651                    	push ecx
  6588 0000046B 669C                    	 pushfd				; (this overwrites reg_ebx)
  6589 0000046D 01C4                    	 add sp, ax			; discard low word of efl
  6590 0000046F 8F06[0200]              	 pop word [reg_efl+2]
  6591 00000473 6A00                    	 push 0
  6592 00000475 9C                      	 pushf				; (this also overwrites reg_ebx)
  6593 00000476 669D                    	 popfd				; clear high word of efl inside debugger (resets AC flag)
  6594 00000478 6653                    	push ebx
  6595 0000047A A1[0000]                	mov ax, word [reg_eax]		; restore ax
  6596 0000047D 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 0000047F 66                      	_386_o32		; mov esp, dword [run_sp]
  6609 00000480 8B26[0000]              	mov sp, word [run_sp]		; restore running stack
  6610 00000484 0326[0000]              	add sp, word [run_sp_reserve]
  6611 00000488 FC                      	cld				; clear direction flag
  6612 00000489 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 0000048A E8(0000)                	call entry_to_code_segsel
  6624 0000048D [F217]                  	dw .code
  6625                                  
  6626                                  	usesection lDEBUG_CODE
  6626          ------------------       note: usesection lDEBUG_CODE
  6627                                  .code:
  6628                                  %endif
  6629                                  
  6630                                  %if _PM
  6631 000017F2 E82B01                  	call handle_mode_changed
  6632                                  %endif
  6633                                  
  6634 000017F5 E8A7F1                  	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 000017F8 51                      	push cx
  6650 000017F9 56                      	push si
  6651 000017FA 57                      	push di
  6652 000017FB 50                      	push ax
  6653 000017FC 53                      	push bx
  6654 000017FD 52                      	push dx
  6655 000017FE 55                      	push bp
  6656                                  
  6657                                  %if _PM
  6658 000017FF E8(0000)                	call ispm
  6659 00001802 7414                    	jz @F			; in PM -->
  6660 00001804 F606[0200]04            	testopt [internalflags], canswitchmode
  6661 00001809 7410                    	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 0000180B 800E[0200]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  6666 00001810 B000                    	mov al, 0
  6667 00001812 E8E4F1                  	call sr_state		; save state
  6668 00001815 E8A7F1                  	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 00001818 E8DB02                  	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 0000181B 8B0E[0000]              	mov cx, word [inttab_number_variable]
  6685                                  %else
  6686                                  	mov cx, inttab_number
  6687                                  %endif
  6688 0000181F E312                    	jcxz .intend
  6689 00001821 BE[0000]                	mov si, inttab
  6690 00001824 BAFFFF                  	mov dx, -1			; always force
  6691                                  .nextint:
  6692 00001827 AC                      	lodsb
  6693 00001828 93                      	xchg ax, bx			; bl = number
  6694 00001829 AD                      	lodsw				; si -> list
  6695 0000182A 96                      	xchg ax, si			; si -> entry, ax -> list
  6696 0000182B 93                      	xchg ax, bx			; al = number, bx -> list
  6697 0000182C E8(0000)                	call UnhookInterruptForce
  6698 0000182F 87DE                    	xchg bx, si			; si -> list
  6699 00001831 E2F4                    	loop .nextint
  6700                                  
  6701                                  .intend:
  6702                                  %endif
  6703                                  
  6704 00001833 5D                      	pop bp
  6705 00001834 5A                      	pop dx
  6706 00001835 5B                      	pop bx
  6707 00001836 58                      	pop ax
  6708 00001837 5F                      	pop di
  6709 00001838 5E                      	pop si
  6710 00001839 59                      	pop cx
  6711                                   %if _DEBUG_COND
  6712                                  	retn
  6713                                   %endif
  6714                                  .skipints:
  6715                                  %endif
  6716                                  
  6717 0000183A 8026[0100]FE            	clropt [reg_efl], 100h		; clear TF
  6718                                  
  6719 0000183F E8(0000)                	call getpsp
  6720 00001842 891E[0000]              	mov word [pspdbe], bx
  6721                                  
  6722 00001846 E8(0000)                	call getint2324			; save debuggee's int 23/24, set debugger's int 23/24
  6723                                  
  6724 00001849 16                      	 push ss
  6725 0000184A 07                      	 pop es
  6726 0000184B E8(0000)                	call setpspdbg			; set PSP of debugger
  6727                                  
  6728 0000184E 800E[0100]30            	setopt [internalflags], debuggerA20|debuggeeA20	; assume A20 is on
  6729                                  %if _PM
  6730 00001853 E8(0000)                	call ispm
  6731 00001856 7420                    	jz .a20done			; assume A20 on. (is this the right thing to do?)
  6732                                  %endif
  6733 00001858 06                      	push es
  6734 00001859 1E                      	push ds
  6735 0000185A 57                      	push di
  6736 0000185B 56                      	push si
  6737 0000185C 51                      	push cx
  6738 0000185D 31F6                    	xor si, si
  6739 0000185F 8EDE                    	mov ds, si			; ds = 0000h
  6740 00001861 4E                      	dec si
  6741 00001862 8EC6                    	mov es, si			; es = FFFFh
  6742 00001864 46                      	inc si				; ds:si = 0000h:0000h =  00000h
  6743 00001865 BF1000                  	mov di, 0010h			; es:di = FFFFh:0010h = 100000h (same address if it overflows)
  6744 00001868 89F9                    	mov cx, di			; 32 byte (16 = 10h word)
  6745 0000186A F3A7                    	repe cmpsw			; compare them and assume A20 line switched off if same
  6746 0000186C 59                      	pop cx
  6747 0000186D 5E                      	pop si
  6748 0000186E 5F                      	pop di
  6749 0000186F 1F                      	pop ds
  6750 00001870 07                      	pop es
  6751 00001871 7505                    	jne .a20done			; not equal, A20 line is switched on -->
  6752                                  					; if equal, the A20 line is probably switched off
  6753 00001873 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 00001878 C606[0000]01            	mov byte [bInDbg], 1
  6793                                  %if _CATCHINT19
  6794 0000187D 813E[0000][0000]        	cmp word [run_int], int19msg
  6795 00001883 7505                    	jne @F
  6796 00001885 800E[0200]20            	setopt [internalflags3], dif3_gotint19
  6797                                  %endif
  6798                                  @@:
  6799 0000188A 813E[0000][0000]        	cmp word [run_int], progtrm
  6800 00001890 7505                    	jnz @F
  6801 00001892 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 00001897 B001                    	mov al, 1		; restore debugger screen
  6810 00001899 E8(0000)                	call swapscreen
  6811                                   %ifn _VXCHGBIOS
  6812 0000189C 06                      	push es
  6813 0000189D B84000                  	mov ax, 0040h
  6814 000018A0 8EC0                    	mov es, ax
  6815 000018A2 26A08400                	mov al, [es:84h]	; did the number of screen rows change?
  6816 000018A6 268A3E6200              	mov bh, [es:62h]
  6817 000018AB 883E[0000]              	mov [vpage], bh
  6818 000018AF 3A06[0000]              	cmp al, [vrows]
  6819 000018B3 A2[0000]                	mov [vrows], al
  6820 000018B6 7419                    	jz @F
  6821                                  
  6822 000018B8 F606[0000]01            	testopt [internalflags6], dif6_vv_mode
  6823 000018BD 7412                    	jz @F
  6824                                  
  6825 000018BF 88C6                    	mov dh, al		; yes. we cannot fully restore, but at least
  6826 000018C1 B200                    	mov dl, 0		;  clear bottom line to ensure the debugger displays
  6827                                  				;  will be seen
  6828 000018C3 B402                    	mov ah, 2		; set cursor position
  6829 000018C5 CD10                    	int 10h
  6830 000018C7 B307                    	mov bl, 7		; BH=video page, BL=attribute
  6831 000018C9 B95000                  	mov cx, 80		; CX=columns
  6832 000018CC B82009                  	mov ax, 0920h		; AL=char to display
  6833 000018CF CD10                    	int 10h
  6834                                  @@:
  6835 000018D1 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 000018D2 E80100                  	call setscreen
  6847                                  %endif
  6848                                  
  6849 000018D5 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 000018D6 C3                      	retn	; will be patched to "push ds" if "/2" cmdline switch and second adapter exists
  6867                                  		; (SMC in section lDEBUG_CODE)
  6868 000018D7 8B16[0000]              	mov dx, [oldcrtp]
  6869 000018DB 8B1E[0000]              	mov bx, [oldcols]
  6870 000018DF A1[0000]                	mov ax, [oldmr]
  6871 000018E2 B94000                  	mov cx, 0040h         ; 0040h is supposed to work in both rm/pm
  6872 000018E5 8ED9                    	mov ds, cx
  6873 000018E7 368B0E[0000]            	mov cx, [ss:oldcsrpos]
  6874 000018EC 80261000CF              	and byte [10h], ~ 30h
  6875 000018F1 80FAB4                  	cmp dl, 0B4h
  6876 000018F4 7505                    	jnz @F
  6877 000018F6 800E100030              	or  byte [10h], 30h
  6878                                  @@:
  6879 000018FB 871E4A00                	xchg bx, [4Ah]
  6880 000018FF 870E5000                	xchg cx, [50h]
  6881 00001903 87166300                	xchg dx, [63h]
  6882 00001907 86064900                	xchg al, [49h]
  6883 0000190B 86268400                	xchg ah, [84h]
  6884 0000190F 1F                      	pop ds
  6885 00001910 8916[0000]              	mov [oldcrtp], dx
  6886 00001914 890E[0000]              	mov [oldcsrpos], cx
  6887 00001918 891E[0000]              	mov [oldcols], bx
  6888 0000191C A3[0000]                	mov [oldmr], ax
  6889 0000191F 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 00001920 BE[0000]                	mov si, convsegs
  6921 00001923 B9[0000]                	mov cx, convsegs.amount
  6922                                  
  6923 00001926 E8(0000)                	call ispm
  6924 00001929 7503E98600              	jz .now_pm
  6925                                  [cpu 286]
  6926                                  .now_86m:
  6927 0000192E F606[0200]40            	testopt [internalflags3], dif3_prior_pm
  6928 00001933 7503E9C200              	jz .from_no_change
  6929                                  %if _MMXSUPP && _MMX_REDETECT
  6930 00001938 E8CF00                  	call mmx_redetect
  6931                                  %endif
  6932                                  .from_pm_now_86m:
  6933                                  .from_pm_now_86m.loop:
  6934 0000193B AD                      	lodsw
  6935 0000193C 97                      	xchg ax, di
  6936 0000193D 81FE[0000]              	cmp si, convsegs.end_fixed
  6937 00001941 770A                    	ja @F
  6938 00001943 8B5502                  	mov dx, word [di + soaSegment]
  6939 00001946 8915                    	mov word [di + soaSegSel], dx
  6940 00001948 E2F1                    	loop .from_pm_now_86m.loop
  6941 0000194A 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 0000194D F606[0200]08            	testopt [internalflags], modeswitched
  6947 00001952 7403E9A300              	jnz .from_done_change		; cancel this -->
  6948                                  
  6949 00001957 F606[0200]04            	testopt [internalflags], canswitchmode
  6950 0000195C 7510                    	jnz @FF
  6951 0000195E 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 00001960 AD                      	lodsw
  6961 00001961 97                      	xchg ax, di
  6962                                  @@:
  6963 00001962 31D2                    	xor dx, dx
  6964 00001964 895502                  	mov word [di + soaSegment], dx
  6965 00001967 8915                    	mov word [di + soaSegSel], dx
  6966 00001969 E2F5                    	loop .from_pm_now_86m.loop.nonfixed.nomodeswitch
  6967 0000196B E98C00                  	jmp .from_done_change
  6968                                  
  6969                                  @@:
  6970 0000196E 51                      	push cx
  6971 0000196F 57                      	push di
  6972 00001970 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 00001971 800E[0200]08            	setopt [internalflags], modeswitched	; set flag for resetmode
  6976 00001976 B000                    	mov al, 0
  6977 00001978 E87EF0                  	call sr_state			; save state
  6978 0000197B E841F0                  	call switchmode 		; switch to PM
  6979                                  		; ! handle_mode_changed not called here !
  6980                                  		; do not call InDOS or other functions using seg/sels
  6981 0000197E 5E                      	pop si
  6982 0000197F 5F                      	pop di
  6983 00001980 EB03                    	jmp @F
  6984                                  
  6985                                  .from_pm_now_86m.loop.nonfixed:
  6986 00001982 AD                      	lodsw
  6987 00001983 97                      	xchg ax, di
  6988 00001984 51                      	push cx
  6989                                  @@:
  6990 00001985 31DB                    	xor bx, bx
  6991 00001987 875D04                  	xchg bx, word [di + soaSelector]
  6992 0000198A B80600                  	mov ax, 0006h
  6993 0000198D CD31                    	int 31h
  6994 0000198F 7214                    	jc @F				; fail -->
  6995 00001991 F6C20F                  	test dl, 15
  6996 00001994 750F                    	jnz @F				; not on a segment boundary -->
  6997 00001996 F7C1F0FF                	test cx, 0FFF0h
  6998 0000199A 7509                    	jnz @F				; >= 1024 KiB -->
  6999 0000199C C1EA04                  	shr dx, 4
  7000 0000199F C1E10C                  	shl cx, 12
  7001 000019A2 09CA                    	or dx, cx
  7002 000019A4 A9                      	db __TEST_IMM16			; (skip xor)
  7003                                  @@:
  7004 000019A5 31D2                    	xor dx, dx			; if no valid segment
  7005 000019A7 895502                  	mov word [di + soaSegment], dx
  7006 000019AA 59                      	pop cx
  7007 000019AB 8915                    	mov word [di + soaSegSel], dx
  7008 000019AD E2D3                    	loop .from_pm_now_86m.loop.nonfixed
  7009 000019AF E86CF0                  	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 000019B2 EB46                    	jmp .from_done_change
  7016                                  __CPU__
  7017                                  
  7018                                  .now_pm:
  7019 000019B4 F606[0200]40            	testopt [internalflags3], dif3_prior_pm
  7020 000019B9 753F                    	jnz .from_no_change
  7021                                  %if _MMXSUPP && _MMX_REDETECT
  7022 000019BB E84C00                  	call mmx_redetect
  7023                                  %endif
  7024                                  .from_86m_now_pm:
  7025                                  .from_86m_now_pm.loop:
  7026 000019BE AD                      	lodsw
  7027 000019BF 97                      	xchg ax, di
  7028 000019C0 81FE[0000]              	cmp si, convsegs.end_fixed
  7029 000019C4 7716                    	ja @F
  7030                                  
  7031 000019C6 8B4504                  	mov ax, word [di + soaSelector]
  7032 000019C9 85C0                    	test ax, ax
  7033 000019CB 750B                    	jnz .no_dosdata_change
  7034 000019CD 8B5D02                  	mov bx, word [di + soaSegment]
  7035 000019D0 B80200                  	mov ax, 0002h
  7036 000019D3 CD31                    	int 31h
  7037 000019D5 894504                  	mov word [di + soaSelector], ax
  7038                                  
  7039                                  .no_dosdata_change:
  7040 000019D8 8905                    	mov word [di + soaSegSel], ax
  7041 000019DA EB1C                    	jmp @FFF
  7042                                  
  7043                                  @@:
  7044                                  		; Magic: Do not modify if called during modeswitching.
  7045 000019DC F606[0200]08            	testopt [internalflags], modeswitched
  7046 000019E1 7517                    	jnz .from_done_change		; cancel this -->
  7047                                  
  7048 000019E3 8B5D02                  	mov bx, word [di + soaSegment]
  7049 000019E6 B80200                  	mov ax, 0002h
  7050 000019E9 CD31                    	int 31h
  7051 000019EB 7302                    	jnc @F
  7052 000019ED 31C0                    	xor ax, ax
  7053                                  @@:
  7054 000019EF 8905                    	mov word [di + soaSegSel], ax
  7055 000019F1 894504                  	mov word [di + soaSelector], ax
  7056 000019F4 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 000019F8 E2C4                    	loop .from_86m_now_pm.loop
  7066                                  %endif
  7067                                  .from_done_change:
  7068                                  .from_no_change:
  7069                                  
  7070                                  
  7071                                  remember_mode:
  7072 000019FA 8026[0200]BF            	clropt [internalflags3], dif3_prior_pm
  7073 000019FF E8(0000)                	call ispm
  7074 00001A02 7505                    	jnz .from_86m
  7075                                  .from_pm:
  7076 00001A04 800E[0200]40            	setopt [internalflags3], dif3_prior_pm
  7077                                  .from_86m:
  7078 00001A09 C3                      	retn
  7079                                  %endif
  7080                                  
  7081                                  
  7082                                  %if _MMXSUPP && _MMX_REDETECT && _PM
  7083                                  mmx_redetect:
  7084 00001A0A C3                      _no386	retn
  7085                                  %ifn _ONLYNON386
  7086                                  subcpu 386
  7087 00001A0B 6650                    	push eax
  7088 00001A0D 6653                    	push ebx
  7089 00001A0F 6651                    	push ecx
  7090 00001A11 6652                    	push edx
  7091                                  
  7092 00001A13 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 00001A18 89E3                    	mov bx, sp		; save current stack pointer to align
  7097 00001A1A 83E4FC                  	and sp, ~3		; align stack to avoid AC fault
  7098 00001A1D 669C                    	pushfd			; push original EFLAGS
  7099 00001A1F 6658                    	pop eax			; get original EFLAGS
  7100 00001A21 6689C1                  	mov ecx, eax		; save original EFLAGS in ECX (including IF)
  7101                                  
  7102 00001A24 663500000400            	xor eax, 40000h		; flip AC bit in EFLAGS
  7103 00001A2A 25FFFD                  	and ax, ~0200h		; clear IF
  7104 00001A2D 6650                    	push eax		; put new EFLAGS value on stack
  7105 00001A2F 669D                    	popfd			; replace EFLAGS value; DI
  7106 00001A31 669C                    	pushfd			; get new EFLAGS
  7107 00001A33 6658                    	pop eax			; store new EFLAGS value in EAX
  7108 00001A35 89C8                    	mov ax, cx		; ignore low bits (including IF)
  7109 00001A37 6639C8                  	cmp eax, ecx
  7110 00001A3A 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 00001A3C 6689C8                  	mov eax, ecx		; get original EFLAGS
  7117 00001A3F 663500002000            	xor eax, 200000h	; flip ID bit in EFLAGS
  7118 00001A45 25FFFD                  	and ax, ~0200h		; clear IF
  7119 00001A48 6650                    	push eax		; save new EFLAGS value on stack
  7120 00001A4A 669D                    	popfd			; replace current EFLAGS value; DI
  7121 00001A4C 669C                    	pushfd			; get new EFLAGS
  7122 00001A4E 6658                    	pop eax			; store new EFLAGS in EAX
  7123 00001A50 89C8                    	mov ax, cx		; ignore low bits (including IF)
  7124                                  
  7125                                  .cpudone_stack_eax_equals_ecx:
  7126 00001A52 6651                    	push ecx
  7127 00001A54 669D                    	popfd			; restore AC,ID bits and IF in EFLAGS (86 Mode)
  7128 00001A56 89DC                    	mov sp, bx		; restore sp
  7129                                  
  7130 00001A58 6639C8                  	cmp eax, ecx		; check if it's changed
  7131 00001A5B 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 00001A5D 6631C0                  	xor eax, eax		; set up input for CPUID instruction
  7140                                  	  [cpu 586]
  7141 00001A60 0FA2                    	 cpuid
  7142                                  	  __CPU__
  7143 00001A62 6683F801                	cmp eax, byte 1
  7144 00001A66 7213                    	jb .cpudone		; if 1 is not a valid input value for CPUID
  7145 00001A68 6631C0                  	xor eax, eax		; otherwise, run CPUID with eax = 1
  7146 00001A6B 6640                    	inc eax
  7147                                  	  [cpu 586]
  7148 00001A6D 0FA2                    	 cpuid
  7149                                  	  __CPU__
  7150 00001A6F 66F7C200008000          	test edx, 80_0000h
  7151 00001A76 0F9506[0000]            	setnz byte [has_mmx]
  7152                                  .cpudone:
  7153 00001A7B 665A                    	pop edx
  7154 00001A7D 6659                    	pop ecx
  7155 00001A7F 665B                    	pop ebx
  7156 00001A81 6658                    	pop eax
  7157 00001A83 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 00001A84 31ED                    	xor bp, bp		; = 0 if no 386
  7173 00001A86 45                      _386	inc bp
  7174 00001A87 45                      _386	inc bp			; = 2 if 386
  7175                                  
  7176 00001A88 1E                      	 push ds
  7177 00001A89 07                      	 pop es
  7178                                  
  7179 00001A8A BE[0000]                	mov si, exctab		; hook several exceptions
  7180                                  %if _DEBUGUPDATESAVE
  7181 00001A8D BF[0000]                	mov di, excsave
  7182                                  %endif
  7183 00001A90 6631D2                  _386	xor edx, edx		; clear edxh
  7184 00001A93 BA[0000]                	mov dx, exc_first
  7185                                  .loopexc:
  7186 00001A96 AC                      	lodsb
  7187 00001A97 88C3                    	mov bl, al
  7188                                  
  7189                                  %if _DEBUGUPDATESAVE
  7190 00001A99 66                      	_386_o32	; push edx
  7191 00001A9A 52                      	push dx			; preserve excXX pointer
  7192 00001A9B B80202                  	mov ax, 0202h
  7193                                  		; (edxh is zero)
  7194 00001A9E CD31                    	int 31h			; cx:(e)dx -> prior handler
  7195 00001AA0 66                      	_386_o32	; xchg eax, edx
  7196 00001AA1 92                      	xchg ax, dx
  7197 00001AA2 66                      	_386_o32	; stosd
  7198 00001AA3 AB                      	stosw			; store offset (dword on 386+, else word)
  7199 00001AA4 91                      	xchg ax, cx
  7200 00001AA5 AB                      	stosw			; store selector
  7201 00001AA6 B80400                  	mov ax, 4
  7202 00001AA9 29E8                    	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7203 00001AAB 01C7                    	add di, ax		; -> next entry of excsave
  7204 00001AAD 66                      	_386_o32	; pop edx
  7205 00001AAE 5A                      	pop dx
  7206                                  %endif
  7207                                  
  7208 00001AAF 8B0E[0000]              	mov cx, word [cssel]	; -> our handler for this exception
  7209 00001AB3 B80302                  	mov ax, 0203h
  7210 00001AB6 CD31                    	int 31h			; set our handler
  7211                                   %ifn _LINK
  7212                                  	add dx, byte exc_second - exc_first
  7213                                   %else
  7214 00001AB8 83C200                  	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 00001ABB 81FE[0000]              	cmp si, endexctab	; if another to go -->
  7220 00001ABF 72D5                    	jb .loopexc
  7221                                  
  7222                                   %if _CATCHPMINT214C
  7223 00001AC1 BE[0000]                	mov si, pminttab	; ds:si -> pminttab
  7224                                    %if _DEBUGUPDATESAVE
  7225 00001AC4 BF[0000]                	mov di, pmintsave	; es:di -> pmintsave
  7226                                    %endif
  7227                                  .loopint:
  7228 00001AC7 AC                      	lodsb			; get interrupt number
  7229 00001AC8 88C3                    	mov bl, al		; bl = interrupt number
  7230                                  
  7231                                    %if _DEBUGUPDATESAVE
  7232 00001ACA 6631D2                  _386	xor edx, edx		; clear edxh
  7233 00001ACD B80402                  	mov ax, 0204h
  7234 00001AD0 CD31                    	int 31h			; cx:(e)dx -> prior handler
  7235 00001AD2 66                      	_386_o32	; xchg eax, edx
  7236 00001AD3 92                      	xchg ax, dx		; (e)ax = offset
  7237 00001AD4 66                      	_386_o32	; stosd
  7238 00001AD5 AB                      	stosw			; store offset (dword on 386+, else word)
  7239 00001AD6 91                      	xchg ax, cx
  7240 00001AD7 AB                      	stosw			; store selector
  7241 00001AD8 B80400                  	mov ax, 4
  7242 00001ADB 29E8                    	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7243 00001ADD 01C7                    	add di, ax		; -> next entry of pmintsave
  7244                                    %endif
  7245                                  
  7246 00001ADF AD                      	lodsw			; ax -> our handler
  7247 00001AE0 6631D2                  _386	xor edx, edx
  7248 00001AE3 92                      	xchg ax, dx		; (e)dx -> our handler
  7249 00001AE4 8B0E[0000]              	mov cx, word [cssel]	; cx:(e)dx -> our handler
  7250 00001AE8 B80502                  	mov ax, 0205h
  7251 00001AEB CD31                    	int 31h
  7252 00001AED 81FE[0000]              	cmp si, pminttab.end
  7253 00001AF1 72D4                    	jb .loopint
  7254                                   %endif
  7255                                  
  7256 00001AF3 E928EF                  	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 00001AF6 31ED                    	xor bp, bp		; = 0 if no 386
  7268 00001AF8 45                      _386	inc bp
  7269 00001AF9 45                      _386	inc bp			; = 2 if 386
  7270                                  
  7271                                  
  7272                                   %if CATCHEXCAMOUNT
  7273                                  		; unhook exceptions
  7274 00001AFA BF[0000]                	mov di, exctab
  7275 00001AFD BE[0000]                	mov si, excsave
  7276                                  .loopexc:
  7277 00001B00 8A1D                    	mov bl, [di]		; bl = exception number
  7278 00001B02 47                      	inc di
  7279 00001B03 66                      	_386_o32	; lodsd
  7280 00001B04 AD                      	lodsw			; load offset (dword on 386+, else word)
  7281 00001B05 66                      	_386_o32	; xchg eax, edx
  7282 00001B06 92                      	xchg ax, dx
  7283 00001B07 AD                      	lodsw			; load selector
  7284 00001B08 91                      	xchg ax, cx		; cx:(e)dx -> prior handler
  7285 00001B09 B80400                  	mov ax, 4
  7286 00001B0C 29E8                    	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7287 00001B0E 01C6                    	add si, ax		; -> next entry of excsave
  7288 00001B10 B80302                  	mov ax, 0203h
  7289 00001B13 CD31                    	int 31h			; set previous handler
  7290 00001B15 81FF[0000]              	cmp di, endexctab	; if another to go -->
  7291 00001B19 72E5                    	jb .loopexc
  7292                                   %endif
  7293                                  
  7294                                  
  7295                                   %if CATCHPMINTAMOUNT
  7296                                  		; unhook interrupts
  7297 00001B1B BF[0000]                	mov di, pminttab	; ds:di -> pminttab
  7298 00001B1E BE[0000]                	mov si, pmintsave	; ds:si -> pmintsave
  7299                                  .loopint:
  7300 00001B21 8A1D                    	mov bl, [di]		; bl = interrupt number
  7301 00001B23 83C703                  	add di, 3		; -> after this pminttab entry
  7302 00001B26 66                      	_386_o32	; lodsd
  7303 00001B27 AD                      	lodsw			; load offset (dword on 386+, else word)
  7304 00001B28 66                      	_386_o32	; xchg eax, edx
  7305 00001B29 92                      	xchg ax, dx
  7306 00001B2A AD                      	lodsw			; load selector
  7307 00001B2B 91                      	xchg ax, cx		; cx:(e)dx -> prior handler
  7308 00001B2C B80400                  	mov ax, 4
  7309 00001B2F 29E8                    	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7310 00001B31 01C6                    	add si, ax		; -> next entry of pmintsave
  7311 00001B33 B80502                  	mov ax, 0205h
  7312 00001B36 CD31                    	int 31h			; set previous handler
  7313 00001B38 81FF[0000]              	cmp di, pminttab.end	; if another to go -->
  7314 00001B3C 72E3                    	jb .loopint
  7315                                   %endif
  7316                                  
  7317 00001B3E E9DDEE                  	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 0000048F 00                      	align 4, db 0
  7391 00000490 01000000                default_pp_count:	dd 1
  7392 00000494 01000000                default_tp_count:	dd 1
  7393 00000498 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 00001B41 E8(0000)                	call guard_re
  7408 00001B44 C706[0000][0000]        	mov word [gg_deferred_message], msg.empty_message
  7409 00001B4A 8326[0000]00            	and word [bb_deferred_message_in_lineout_behind], 0
  7410 00001B4F 8026[0000]F7            	clropt [internalflags2], dif2_gg_is_gg
  7411 00001B54 8026[0300]2B            	clropt [internalflags], 		tt_while | tt_silent_mode | tt_no_bb | tt_no_bb_first
  7413 00001B59 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 00001B5E 3C2E                    	cmp al, '.'
  7421 00001B60 7520                    	jne .no_dot
  7422                                  
  7423 00001B62 AD                      	lodsw
  7424 00001B63 25DFDF                  	and ax, TOUPPER_W
  7425 00001B66 3D4E42                  	cmp ax, "NB"
  7426 00001B69 7411                    	je .dot_nb
  7427                                  		; TP.SB, T.SB, P.SB: trace/proceed without bb for first step
  7428 00001B6B 3D5342                  	cmp ax, "SB"
  7429 00001B6E 7405                    	je .dot_sb
  7430 00001B70 4E                      	dec si
  7431 00001B71 4E                      	dec si
  7432 00001B72 E9(0000)                	jmp error
  7433                                  
  7434                                  .dot_sb:
  7435 00001B75 800E[0300]80            	setopt [internalflags], tt_no_bb_first
  7436 00001B7A EB05                    	jmp .dot_common
  7437                                  
  7438                                  .dot_nb:
  7439 00001B7C 800E[0300]40            	setopt [internalflags], tt_no_bb
  7440                                  .dot_common:
  7441 00001B81 AC                      	lodsb
  7442                                  .no_dot:
  7443 00001B82 E86301                  	call parseql		; process =addr
  7444 00001B85 E8(0000)                	call skipcomm0		; skip any white space
  7445                                  
  7446 00001B88 BA0400                  	mov dx, opt3_pp_no_paging
  7447 00001B8B 8B1E[9204]              	mov bx, word [default_pp_count + 2]
  7448 00001B8F 8B0E[9004]              	mov cx, word [default_pp_count]
  7449 00001B93 F606[0100]10            	testopt [internalflags2], dif2_is_pp
  7450 00001B98 751D                    	jnz @F
  7451 00001B9A BA0200                  	mov dx, opt3_tp_no_paging
  7452 00001B9D 8B1E[9604]              	mov bx, word [default_tp_count + 2]
  7453 00001BA1 8B0E[9404]              	mov cx, word [default_tp_count]
  7454 00001BA5 F606[0300]08            	testopt [internalflags], tt_p
  7455 00001BAA 750B                    	jnz @F
  7456 00001BAC BA0100                  	mov dx, opt3_tt_no_paging
  7457 00001BAF 8B1E[9A04]              	mov bx, word [default_tt_count + 2]
  7458 00001BB3 8B0E[9804]              	mov cx, word [default_tt_count]
  7459                                  @@:				; bx:cx = default count
  7460                                  
  7461 00001BB7 8516[0000]              	test word [options3], dx
  7462 00001BBB 7405                    	jz @F
  7463 00001BBD 8026[0000]F7            	clropt [internalflags], pagedcommand
  7464                                  @@:
  7465                                  
  7466                                  		; Initialise auxbuff pointers.
  7467 00001BC2 E80B01                  	call tpg_initialise_empty_auxbuff
  7468                                  
  7469 00001BC5 E8(0000)                	call iseol?
  7470                                  %if _LINK_COMPAT
  7471 00001BC8 7503                    	jne @F
  7472 00001BCA E98A00                  	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 00001BCD E8(0000)EB02[0000]      	nearcall getdword	; bx:dx = given count
  7478                                  
  7479 00001BD4 53                      	push bx
  7480 00001BD5 52                      	push dx			; push count
  7481 00001BD6 E8(0000)                	call skipcomm0
  7482 00001BD9 E8(0000)                	call iseol?
  7483 00001BDC 7477                    	je .no_while
  7484 00001BDE 4E                      	dec si
  7485 00001BDF BA[0000]                	mov dx, msg.while
  7486 00001BE2 E8(0000)                	call isstring?
  7487 00001BE5 7405                    	je .found_while
  7488                                  
  7489 00001BE7 E8B800                  	call .handle_silent	; (error if no SILENT keyword)
  7490                                  
  7491 00001BEA EB69                    	jmp .no_while
  7492                                  
  7493                                  
  7494                                  .found_while:
  7495 00001BEC E8(0000)                	call skipcomma
  7496 00001BEF 4E                      	dec si
  7497 00001BF0 89F1                    	mov cx, si
  7498 00001BF2 AC                      	lodsb
  7499 00001BF3 E8(0000)EB02[0000]      	nearcall getexpression
  7500 00001BFA E8(0000)EB02[0000]      	nearcall toboolean
  7501 00001C01 E8(0000)                	call skipcomm0
  7502 00001C04 52                      	push dx
  7503 00001C05 56                      	push si
  7504 00001C06 E8(0000)                	call iseol?		; expect end of line here
  7505 00001C09 7404                    	je .no_while_silent
  7506                                  
  7507 00001C0B 4E                      	dec si
  7508 00001C0C E89300                  	call .handle_silent
  7509                                  
  7510                                  .no_while_silent:
  7511 00001C0F 5E                      	pop si
  7512 00001C10 5A                      	pop dx
  7513 00001C11 85D2                    	test dx, dx		; condition true now ?
  7514 00001C13 750F                    	jnz @F
  7515                                  
  7516 00001C15 BA[0000]                	mov dx, msg.while_not_true
  7517 00001C18 E8(0000)                	call putsz
  7518 00001C1B B83601                  	mov ax, 0136h
  7519 00001C1E E8(0000)                	call setrc
  7520 00001C21 E9(0000)                	jmp cmd3
  7521                                  
  7522                                  @@:
  7523                                  		; (si + 1) -> line terminator (13, ';', 0) or next keyword
  7524                                  @@:
  7525 00001C24 4E                      	dec si			; -> terminator, or blank
  7526 00001C25 807CFF20                	cmp byte [si - 1], 32	; another blank at end ?
  7527 00001C29 74F9                    	je @B			; yes -->
  7528 00001C2B 807CFF09                	cmp byte [si - 1], 9
  7529 00001C2F 74F3                    	je @B			; yes -->
  7530 00001C31 807CFF2C                	cmp byte [si - 1], ','	; comma at end ?
  7531 00001C35 74ED                    	je @B			; yes -->
  7532 00001C37 89F0                    	mov ax, si
  7533 00001C39 29C8                    	sub ax, cx		; ax = length of expression
  7534 00001C3B 3D[FFFF]                	cmp ax, while_buffer.length - 1
  7535 00001C3E 7603E9(0000)            	ja error
  7536 00001C43 57                      	push di
  7537 00001C44 BF[0000]                	mov di, while_buffer
  7538 00001C47 89CE                    	mov si, cx		; -> expression start
  7539 00001C49 91                      	xchg cx, ax		; cx = length of expression
  7540 00001C4A F3A4                    	rep movsb		; store expression
  7541 00001C4C B000                    	mov al, 0
  7542 00001C4E AA                      	stosb			; terminate string
  7543 00001C4F 5F                      	pop di
  7544                                  
  7545 00001C50 800E[0300]04            	setopt [internalflags], tt_while
  7546                                  .no_while:
  7547 00001C55 59                      	pop cx
  7548 00001C56 5B                      	pop bx			; bx:cx = given count
  7549                                  
  7550                                  .ppt1:
  7551 00001C57 85DB                    	test bx, bx
  7552 00001C59 7507                    	jnz @F
  7553 00001C5B 85C9                    	test cx, cx
  7554 00001C5D 7503E9(0000)            	jz error		; must be at least 1, else error -->
  7555                                  @@:
  7556 00001C62 53                      	push bx
  7557 00001C63 51                      	push cx
  7558                                  
  7559 00001C64 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  7562                                  
  7563 00001C69 F606[0200]04            	testopt [options], tp_do_not_skip_bp
  7564 00001C6E 752C                    	jnz .do_not_skip_cseip
  7565 00001C70 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
  7566                                  
  7567 00001C75 803E[0000]00            	cmp byte [eqflag], 0
  7568 00001C7A 7508                    	jne .cseip_take_eql
  7569                                  
  7570 00001C7C 66                      	_386_PM_o32		; xor ecx, ecx
  7571 00001C7D 31C9                    	xor cx, cx
  7572 00001C7F E83CEC                  	call get_cseip_ecx_linear
  7573 00001C82 EB0C                    	jmp .got_cseip
  7574                                  
  7575                                  .cseip_take_eql:
  7576 00001C84 8B1E[0400]              	mov bx, word [eqladdr + 4]
  7577 00001C88 66                      	_386_PM_o32		; mov edx, dword [eqladdr]
  7578 00001C89 8B16[0000]              	mov dx, word [eqladdr]
  7579 00001C8D E83AEC                  	call getlinear_d_b
  7580                                  .got_cseip:
  7581 00001C90 7303E9(0000)            	jc error
  7582 00001C95 A3[0000]                	mov word [gg_first_cseip_linear], ax
  7583 00001C98 8916[0200]              	mov word [gg_first_cseip_linear + 2], dx
  7584                                  .do_not_skip_cseip:
  7585                                  
  7586 00001C9C 59                      	pop cx
  7587 00001C9D 5B                      	pop bx
  7588                                  
  7589 00001C9E E86C00                  	call seteq		; make the = operand take effect
  7590 00001CA1 C3                      	retn
  7591                                  
  7592                                  
  7593                                  .handle_silent:
  7594 00001CA2 BA[0000]                	mov dx, msg.silent
  7595 00001CA5 E8(0000)                	call isstring?
  7596 00001CA8 7403E9(0000)            	jne error
  7597 00001CAD E8(0000)                	call skipcomma
  7598 00001CB0 4E                      	dec si
  7599 00001CB1 E8(0000)                	call skipequals
  7600 00001CB4 E8(0000)                	call iseol?
  7601 00001CB7 740E                    	je .no_silent_mode_number
  7602                                  
  7603 00001CB9 E8(0000)EB02[0000]      	nearcall getword
  7604 00001CC0 8916[0000]              	mov word [tt_silent_mode_number], dx
  7605 00001CC4 E8(0000)                	call chkeol
  7606                                  
  7607                                  .no_silent_mode_number:
  7608 00001CC7 E8(0000)                	call guard_auxbuff.1_or_2
  7609 00001CCA 800E[0300]10            	setopt [internalflags], tt_silent_mode
  7610 00001CCF 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 00001CD0 8B16[0000]              	mov dx, word [auxbuff_behind_last_silent]
  7622 00001CD4 F606[0200]10            	testopt [options6], opt6_rh_mode
  7623 00001CD9 7508                    	jnz .last
  7624                                  %endif
  7625                                  .reset:
  7626                                  %if _PM
  7627 00001CDB 8B16[0000]              	mov dx, word [auxbuff_switchbuffer_size]
  7628                                  %else
  7629                                  	xor dx, dx
  7630                                  %endif
  7631 00001CDF 8916[0000]              	mov word [auxbuff_behind_last_silent], dx
  7632                                  .last:
  7633                                  %if _RH
  7634 00001CE3 8916[0000]              	mov word [auxbuff_start_silent], dx
  7635                                  %endif
  7636 00001CE7 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 00001CE8 C606[0000]00            	mov byte [eqflag], 0	; mark '=' as absent
  7650 00001CED 3C3D                    	cmp al, '='
  7651 00001CEF 751B                    	jne peq1		; if no '=' operand
  7652 00001CF1 E8(0000)                	call skipwhite
  7653 00001CF4 8B1E[0000]              	mov bx, word [reg_cs]	; default segment
  7654 00001CF8 E8(0000)EB02[0000]      	nearcall getaddrX	; get the address into bx:(e)dx
  7655 00001CFF 66                      	_386_PM_o32	; mov dword [eqladdr], edx
  7656 00001D00 8916[0000]              	mov word [eqladdr+0], dx
  7657 00001D04 891E[0400]              	mov word [eqladdr+4], bx
  7658 00001D08 FE06[0000]              	inc byte [eqflag]
  7659                                  peq1:
  7660 00001D0C 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 00001D0D 803E[0000]00            	cmp byte [eqflag], 0
  7669 00001D12 7417                    	je .return		; if no `=' operand
  7670 00001D14 A1[0000]                	mov ax, word [eqladdr+0]
  7671 00001D17 A3[0000]                	mov word [reg_eip], ax
  7672                                  %if _PM
  7673 00001D1A A1[0200]                	mov ax, word [eqladdr+2]
  7674 00001D1D A3[0200]                	mov word [reg_eip+2], ax
  7675                                  %endif
  7676 00001D20 A1[0400]                	mov ax, word [eqladdr+4]
  7677 00001D23 A3[0000]                	mov word [reg_cs], ax
  7678 00001D26 C606[0000]00            	mov byte [eqflag], 0	; clear the flag
  7679                                  .return:
  7680 00001D2B C3                      	retn
  7681                                  %endif	; !_LOADER
  7682                                  
  7683                                  usesection lDEBUG_CODE
  7683          ------------------       note: usesection lDEBUG_CODE
  7684                                  
  7685                                  ..@run_access_end:
