     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
   209                              <2> %else
   210                              <2> 	usesection lDEBUG_CODE
   210          ------------------  <2>  note: usesection lDEBUG_CODE
   211                              <2> %endif
   212                              <2> section_of FloatToStr
   213                              <2> 
   214                              <2> 
   215                              <2>  %if _DUALCODE && _EXPRDUALCODE
   216                              <2> 	usesection lDEBUG_CODE2
   217                              <2>  %else
   218                              <2> 	usesection lDEBUG_CODE
   218          ------------------  <2>  note: usesection lDEBUG_CODE
   219                              <2>  %endif
   220                              <2> 
   221                              <2> section_of getofsforbx, checkpointer, getrangeX
   222                              <2> section_of getrangeX_have_address_need_length
   223                              <2> section_of getrange, getaddr, getofsforbx_remember_bitness
   224                              <2> section_of remember_bitness, getaddr_taken
   225                              <2> section_of getstr, get_length, get_length_keyword
   226                              <2> section_of isbracketorunaryoperator?, isunaryoperator?, isoperator?
   227                              <2> section_of ..@call_operator_dispatchers
   228                              <2> section_of isseparator?, istype?, isunsignedtype?
   229                              <2> section_of handlesegment, handle3byte, handlebyte, handleword
   230                              <2> section_of handledword, handlepointer
   231                              <2> section_of uoh_abs, uoh_minus, calculate_minus_bxdx, uoh_plus
   232                              <2> section_of uoh_not_bitwise, uoh_not_boolean
   233                              <2> section_of od_minus, od_plus, od_multiply, od_divide, od_modulo, od_retn
   234                              <2> section_of od_above, od_below, od_equal, od_not, od_or, od_and, od_xor
   235                              <2> section_of od_cond, od_o, od_a, od_x, od_c, od_string_common
   236                              <2> section_of of_modulo, of_minus, of_plus, or_hhtype, of_multiply
   237                              <2> section_of set_hhtype, of_divide, of_power
   238                              <2> section_of of_compare_below_equal, of_compare_below, of_compare_not_equal
   239                              <2> section_of of_compare_equal, of_compare_above_equal, of_compare_above
   240                              <2> section_of toboolean, of_helper_compare_true, of_rightop, of_helper_compare
   241                              <2> section_of of_shift_right, of_shift_right_signed, of_shift_left
   242                              <2> section_of of_helper_getshiftdata, of_bit_mirror
   243                              <2> section_of of_or_bitwise, or_hhtype_1, of_or_boolean, of_clr_bitwise
   244                              <2> section_of of_and_bitwise, of_and_boolean, of_xor_bitwise, of_xor_boolean
   245                              <2> section_of of_helper_retbool, of_helper_getbool
   246                              <2> 
   247                              <2> section_of var_cip_setup, var_csp_setup, var_lfsr_setup, var_reverselfsr_setup
   248                              <2> section_of var_dpspsel_setup, var_seldbg_setup, var_mt_setup
   249                              <2> section_of var_ioi_setup, var_psps_setup, var_ppr_setup, var_ppi_setup
   250                              <2> section_of var_iok_setup, var_rhcount_setup
   251                              <2> section_of var_get_psp_segment, var_get_psp_selector
   252                              <2> section_of var_bootldpunit_setup, var_bootsdpunit_setup, var_bootydpunit_setup
   253                              <2> section_of var_bootldppart_setup, var_bootsdppart_setup, var_bootydppart_setup
   254                              <2> section_of var_bootunitflags_setup
   255                              <2> 
   256                              <2> section_of issymbol?, isvariable?, var_mm_setup, var_ri_setup, var_ysf_setup
   257                              <2> section_of default_variable_setup
   258                              <2> section_of var_ext_setup
   259                              <2> section_of var_ext_setup_done
   260                              <2> 
   261                              <2> section_of getstmmxdigit
   262                              <2> section_of getexpression.lit_ishexdigit?, getexpression.lit_isdigit?
   263                              <2> section_of of_cond, count_unary_operators, count_unary_operators_restrict
   264                              <2> section_of get3byte.checksignificantbits, getbyte, checksignificantbitscommon
   265                              <2> section_of getnyb, get_value_range
   266                              <2> 
   267                              <2> section_of getaddrX, getword, getdword, getexpression
   268                              <2> 
   269                              <2> section_of getrangeX.lines, getrangeX.ecx_and_0_valid
   270                              <2> section_of getrange.lines, getrange.ecx_and_0_valid, get_length.lines
   271                              <2> section_of getrangeX.lines_and_uu, getrange.lines_and_uu
   272                              <2> section_of isseparator?.except_L_or_dot, isvariable?.return_name
   273                              <2> section_of getword.checksignificantbits, getbyte.checksignificantbits
   274                              <2> 
   275                              <2> section_of seg_bx_to_sel
   276                              <2> section_of getexpression.countsignificantbits
   277                              <2> section_of ..@rr_checksignificantbits, ..@rr_operatordispatchers
   278                              <2> section_of ..@rr_operatorfunctions, ..@parsecm_getaddr
   279                              <2> section_of stack_check.internal
   280                              <2> 
   281                              <2> 
   282                              <2> 	usesection INIT
   282          ------------------  <2>  note: usesection INIT
   283                              <2> section_of init_capitalise
   284                              <2> section_of init_skipwhite, init_skipwh0
   285                              <2> section_of init_skipcomma, init_skipcomm0
   286                              <2> section_of init_skipequals
   287                              <2> 
   288                              <2> 
   289                              <2> 	usesection lDEBUG_DATA_ENTRY
   289          ------------------  <2>  note: usesection lDEBUG_DATA_ENTRY
   290                              <2> section_of entry_retn
   291                              <2> 
   292                              <2> 
   293                              <2> %if _LINK
   294                              <2>  %include "extern.mac"
     1                              <3> 
     2                              <3> ; expr.asm
     3                              <3>  extern PPLEN, PPLEN_ONLY_PREFIXES, a_addr, alloc_seg, alloc_size
     4                              <3>  extern amis_multiplex_number, asm_options, asm_startoptions
     5                              <3>  extern auxbuff_current_size, auxbuff_segorsel, behind_r_u_addr
     6                              <3>  extern bp_offset, code_seg, code_size, d_addr, dcount_addr
     7                              <3>  extern dcpm_addr, dd_default_length, dd_default_lines, dd_text_and
     8                              <3>  extern debuggerfunction, default_pp_count, default_tp_count
     9                              <3>  extern default_tt_count, device_header_address, device_mcb_paragraphs
    10                              <3>  extern dwcount_addr, dz_addr, e_addr, encodedmach87, entryseg_size
    11                              <3>  extern env_size, envseg, erc, errret
    12                              <3>  extern extdata, extdata_size, extdata_used, extseg, extseg_size
    13                              <3>  extern extseg_used, flagbits.amount, flagnames, flagvaron
    14                              <3>  extern getrange_is_uu, getrange_lines, has_mmx, hhresult
    15                              <3>  extern history.segorsel, historyseg_size, immseg, input_file_handles
    16                              <3>  extern input_file_handles.active, internalflags, internalflags2
    17                              <3>  extern internalflags3, intr8_limit, io_columns, io_columns_getline
    18                              <3>  extern io_end_buffer, io_flags, io_levels, io_rows, io_start_buffer
    19                              <3>  extern line_out, line_out_end, linkinfoaddress, load_data
    20                              <3>  extern load_input_file, load_input_file.active, load_unit_flags
    21                              <3>  extern loaddata_loadedfrom, machine, maxmachinetype, messageseg
    22                              <3>  extern messageseg_size, mmxbuff, msg.as, msg.end, msg.executing
    23                              <3>  extern msg.executing_value_range, msg.from, msg.in, msg.length
    24                              <3>  extern msg.linear, msg.lines, msg.lr, msg.nd, msg.nottaken
    25                              <3>  extern msg.nt, msg.or, msg.questionmark, msg.r, msg.stack_overflow
    26                              <3>  extern msg.stack_overflow.caller, msg.stack_overflow.cond
    27                              <3>  extern msg.stack_overflow.indirection, msg.stack_overflow.linear
    28                              <3>  extern msg.stack_overflow.parens, msg.stack_overflow.precedence
    29                              <3>  extern msg.stack_overflow.value_in, msg.t, msg.taken, msg.to
    30                              <3>  extern msg.value, msgtable_value_range, options, options2, parent
    31                              <3>  extern ppbytes, priorrc, psp22, pspdbe, pspdbg
    32                              <3>  extern qqtermcode, rc_count, rc_limit, re_count, re_limit
    33                              <3>  extern reading_access_variables, reg16names, reg8names, reg_cs
    34                              <3>  extern reg_ds, reg_efl, reg_eip, reg_esp, search_results
    35                              <3>  extern serial_columns, serial_fifo_size, serial_keep_timeout
    36                              <3>  extern serial_rows, serial_use_baseport, serial_use_dl
    37                              <3>  extern serial_use_fifo, serial_use_intnum, serial_use_irqmask
    38                              <3>  extern serial_use_params, serial_var_baseport, serial_var_dl
    39                              <3>  extern serial_var_fifo, serial_var_intnum, serial_var_irqmask
    40                              <3>  extern serial_var_params, sscounter, stack, startoptions
    41                              <3>  extern table_length_keywords, throwsp, transfer_ext_cx
    42                              <3>  extern try_amis_multiplex_number, try_debugger_amis_multiplex_number
    43                              <3>  extern types, types.addresses_minus_end, types.end, u_addr
    44                              <3>  extern usertermcode, uu_default_length, uu_default_lines, vregs
    45                              <3>  extern vregs.amount, writing_access_variables
    46                              <3>  extern flagbits, regs
    47                              <3> 
    48                              <3> ; run.asm
    49                              <3>  extern ..@aa_access_end, ..@aa_access_start, ..@dd_access_end
    50                              <3>  extern ..@dd_access_start, ..@ee_access_end, ..@ee_access_start
    51                              <3>  extern ..@ee_interactive_access_end, ..@ee_interactive_access_start
    52                              <3>  extern ..@hh_indirection_memory_access_end
    53                              <3>  extern ..@hh_indirection_memory_access_start
    54                              <3>  extern ..@readmem_fault_skip_4_near_call, ..@rr_access_end
    55                              <3>  extern ..@rr_access_start, ..@rr_variable_read_access_end
    56                              <3>  extern ..@rr_variable_read_access_start
    57                              <3>  extern ..@rr_variable_write_access_end
    58                              <3>  extern ..@rr_variable_write_access_start, ..@sss_access_end
    59                              <3>  extern ..@sss_access_start, ..@uu_access_end, ..@uu_access_start
    60                              <3>  extern ..@uu_referenced_memory_access_end
    61                              <3>  extern ..@uu_referenced_memory_access_start, ..@uu_simulate_cmps_end
    62                              <3>  extern ..@uu_simulate_cmps_start, ..@uu_simulate_scas_end
    63                              <3>  extern ..@uu_simulate_scas_start, InDOS_or_BIOS_IO, PPLEN_ONLY_STRING
    64                              <3>  extern auxbuff_behind_last_silent
    65                              <3>  extern auxbuff_start_silent, bInDbg, b_bplist.bp, b_bplist.counter
    66                              <3>  extern b_bplist.disabled_mask, b_bplist.idbuffer, b_bplist.used_mask
    67                              <3>  extern b_bplist.when, bb_deferred_message_in_lineout_behind
    68                              <3>  extern bp_display_offset, calcpointbit, cmd2_reset_re, cmd_goto
    69                              <3>  extern debug22.cleartraceflag, decbyte, dmycmd, dumpregs_extended
    70                              <3>  extern enable_rh, entry_to_code_seg, entry_to_code_segsel, eqflag
    71                              <3>  extern eqladdr, exccsip, exception_csip, exception_stack, excloc
    72                              <3>  extern g_bplist.bp, g_bplist.used_count, get_set_id_offset_length
    73                              <3>  extern getc_if_any, getcseipbyte, getint2324, getpsp
    74                              <3>  extern gg_deferred_message, gg_first_cseip_linear
    75                              <3>  extern gg_next_cseip_linear, guard_auxbuff.1_or_2, idle, in_getinput
    76                              <3>  extern int19msg, internalflags6, intr8_counter, lastcmd, msg.again
    77                              <3>  extern msg.alreadytsr, msg.area_aa_access, msg.area_dd_access
    78                              <3>  extern msg.area_ee_access, msg.area_ee_interactive_access
    79                              <3>  extern msg.area_hh_indirection_memory_access, msg.area_rr_access
    80                              <3>  extern msg.area_rr_variable_read_access
    81                              <3>  extern msg.area_rr_variable_write_access, msg.area_run_access
    82                              <3>  extern msg.area_sss_access, msg.area_uu_access
    83                              <3>  extern msg.area_uu_referenced_memory_access
    84                              <3>  extern msg.area_uu_simulate_cmps, msg.area_uu_simulate_scas
    85                              <3>  extern msg.bb_hit.1, msg.bb_hit.2.counter, msg.bb_hitpass_id.after
    86                              <3>  extern msg.bb_hitpass_id.long, msg.bb_hitpass_id.short, msg.bb_pass.1
    87                              <3>  extern msg.cant_bp_linear, msg.cant_bp_linear.address1
    88                              <3>  extern msg.cant_bp_reason, msg.cant_bp_reason0, msg.cant_bp_reason1
    89                              <3>  extern msg.cant_bp_reason2, msg.cant_bp_reason3
    90                              <3>  extern msg.cant_bp_reason3.value, msg.cant_bp_reasonu
    91                              <3>  extern msg.cant_bp_restore, msg.cant_bp_restore.value
    92                              <3>  extern msg.cant_bp_the, msg.cant_bp_type_gg
    93                              <3>  extern msg.cant_bp_type_permanent, msg.cant_bp_type_permanent.index
    94                              <3>  extern msg.cant_bp_type_proceed, msg.cant_bp_write, msg.ctrlc
    95                              <3>  extern msg.empty_message, msg.goto, msg.invalidpsp, msg.list
    96                              <3>  extern msg.list_bp.address1, msg.list_bp.first, msg.list_bp.second
    97                              <3>  extern msg.list_bp.third, msg.list_bp.value, msg.list_bp_csip_16
    98                              <3>  extern msg.list_bp_none, msg.list_bp_not_cseip, msg.notyettsr
    99                              <3>  extern msg.nowattached, msg.nowtsr1, msg.nowtsr2, msg.psphooked
   100                              <3>  extern msg.pspnotfound, msg.remember, msg.selfownedpsp, msg.silent
   101                              <3>  extern msg.warnprefix, msg.while, msg.while_not_true
   102                              <3>  extern msg.while_terminated_after, msg.while_terminated_before
   103                              <3>  extern oldcols, oldcrtp, oldcsrpos, oldmr, options3
   104                              <3>  extern options6, pp_instruction, pp_operand, progexit, progtrm
   105                              <3>  extern rc, reg_eax, reg_es, reg_gs, reg_ss
   106                              <3>  extern run_int, run_sp, run_sp_reserve, savesp, setcseipbyte
   107                              <3>  extern setint2324, setpsp, setpspdbg
   108                              <3>  extern showstring, silence_dump, spadjust, swapscreen
   109                              <3>  extern tmode0, tmode1, tmodes, tmodev, tpg_possible_breakpoint
   110                              <3>  extern tpg_proceed_bp, tt_silent_mode_number, vpage, vrows
   111                              <3>  extern while_buffer, while_buffer.length, writemem
   112                              <3> 
   113                              <3>  extern ..@getcseipbyte_fault_skip_2_near_call
   114                              <3>  extern ..@setcseipbyte_fault_skip_2_near_call
   115                              <3>  extern ..@writemem_fault_skip_4_near_call_a
   116                              <3>  extern ..@writemem_fault_skip_4_near_call_b, int0Cmsg, int0Dmsg
   117                              <3>  extern int0msg, int18msg, int1msg, int3msg, int6msg
   118                              <3>  extern int8_kbd_msg, int8msg, runint_ctrlc_msg, serial_flags
   119                              <3> 
   120                              <3> ; bb.asm
   121                              <3>  extern ..@bb_id_length, ..@bb_id_start, ..@bb_saved_linear
   122                              <3>  extern ..@bb_when_length, ..@bb_when_start, b_bplist.id
   123                              <3>  extern b_bplist.idbuffer.free
   124                              <3>  extern b_bplist.whenbuffer, b_bplist.whenbuffer.free
   125                              <3>  extern bootcmd, crlf, msg.all, msg.at
   126                              <3>  extern msg.bb_no_new, msg.bb_when, msg.boot, msg.bp, msg.bpaddress
   127                              <3>  extern msg.bpcontent, msg.bpcounter, msg.bpdisabled, msg.bpenabled
   128                              <3>  extern msg.bpnone, msg.bpnone_at, msg.bpunused, msg.counter
   129                              <3>  extern msg.existing, msg.id, msg.new, msg.notbu, msg.number
   130                              <3>  extern msg.offset, msg.when, prnquit
   131                              <3> 
   132                              <3> ; rr.asm
   133                              <3>  extern InDOS_or_BIOS_output, cmdline_buffer
   134                              <3>  extern cmdline_buffer.end, cmdline_buffer.position, disflags, ee0a
   135                              <3>  extern error_expr, flagbits_for_40, flagbits_for_80, flagsoff
   136                              <3>  extern flagsoff_style2, flagsoff_style3, flagson, flagson_style23
   137                              <3>  extern get_memref_index_bx, getline00, getline_reset_notatty
   138                              <3>  extern guard_rc, hexnyb.common, hhtype, hhvar, in_re
   139                              <3>  extern mask_4byte, masks, memrefs, memrefs.free, msg.3byte
   140                              <3>  extern msg.abort, msg.append, msg.byte, msg.count, msg.dword
   141                              <3>  extern msg.highlight, msg.internal_error_no_mmx, msg.readonly
   142                              <3>  extern msg.readonly_mem, msg.regs386, msg.regs386_off, msg.regs386_on
   143                              <3>  extern msg.replace, msg.rh, msg.rv_mode.before, msg.rv_mode_r86m
   144                              <3>  extern msg.rv_mode_v86m, msg.rvd, msg.rvd_deviceheader
   145                              <3>  extern msg.rvd_not_device, msg.rvd_size, msg.rvm, msg.rvp
   146                              <3>  extern msg.rvp_application, msg.rvp_boot, msg.rvp_device
   147                              <3>  extern msg.rvp_device_attached, msg.rvp_tsr, msg.rvv
   148                              <3>  extern msg.unexpected_auxbuff_guard, msg.unhighlight, msg.vm_auxseg
   149                              <3>  extern msg.vm_codeseg, msg.vm_dataseg, msg.vm_entryseg, msg.vm_hisseg
   150                              <3>  extern msg.vm_messageseg, msg.vp_dparent, msg.vp_dpra
   151                              <3>  extern msg.vp_dpspsegment, msg.vp_parent, msg.vp_pra
   152                              <3>  extern msg.vp_pspsegment, msg.word, operatorfunctions, psp_parent
   153                              <3>  extern psp_pra, puts_break_line_more, putsline_break_line, re_buffer
   154                              <3>  extern re_buffer.end, re_buffer.position, re_sp, regs_prior
   155                              <3>  extern regs_prior.size, retn_expr, rh_count_number
   156                              <3>  extern rh_display_with_count, shortflagbits, shortflagbits.amount
   157                              <3>  extern shortflagsoff, shortflagson, silence_dump.rh
   158                              <3>  extern silence_dump.rh.all, table_getline_prepare_ldebug
   159                              <3>  extern table_getline_prepare_ms_debug, terminate_silent_dump
   160                              <3>  extern terminate_silent_dump.if_nonnull
   161                              <3> 
   162                              <3> ; rr.asm
   163                              <3>  extern flagbits_for_shl, regs_prior.size_w
   164                              <3> 
   165                              <3> ; aa.asm
   166                              <3>  extern REP_LEN, SEGP_LEN, attach
   167                              <3>  extern ext_aa_after_getline_handler, ext_aa_before_getline_handler
   168                              <3>  extern ext_aa_inject_handler, immasm_length, immasm_rel1632_target
   169                              <3>  extern immasm_rel8_target, msg.aa_internal_error, msg.attach
   170                              <3>  extern prefixlist.after_segment, replist, segprfxtab, showmach
   171                              <3>  extern skipalpha, sm1
   172                              <3> 
   173                              <3> ; uu.asm
   174                              <3>  extern A32P_LEN, GROUP7, MN_DB, MN_LOCK, MN_LOOP
   175                              <3>  extern MN_LOOPNZ, MN_LOOPZ, MN_REP, MN_REPE, MN_REPNE
   176                              <3>  extern MN_SEG, MN_WAIT, N_LOCK, N_LTABA, N_LTABO
   177                              <3>  extern N_WTAB, O32P_AMOUNT, OPTYPES_BASE, REP_DIFF_LEN, REP_SAME_LEN
   178                              <3>  extern SFPGROUP3, SGROUP4, SPARSE_BASE, a32prfxtab, dismach
   179                              <3>  extern dmflags, has_87, immasm_far_target, immasm_imm16, locktab
   180                              <3>  extern ltaba1, ltabo1, mach_87, mnlist, mnlist_a_suffix_allowed
   181                              <3>  extern mnlist_o_suffix_allowed, mnlist_o_suffix_required
   182                              <3>  extern msg.condjump, msg.condnotjump, msg.memrefs_invalid_internal
   183                              <3>  extern msg.uninstall, msg.uu_internal_error, msg.uu_too_many_repeat
   184                              <3>  extern needsmath, needsmath_L, needsmsg, needsmsg.digit_6_ofs
   185                              <3>  extern needsmsg.digit_x_ofs, needsmsg_L, o32prfxtab, obsmach
   186                              <3>  extern obsolete, obsolete_L, opindex, opinfo, oplists
   187                              <3>  extern optypes, ppbytes.string, ppbytes.string_amount, reg_ebp
   188                              <3>  extern reg_ebx, reg_ecx, reg_edi, reg_esi, reg_fs
   189                              <3>  extern regmem, rgnam16, rgnam816, segrgnam, sibbyte
   190                              <3>  extern sqztab, tab_to, uninstall, unused, wtab1
   191                              <3> 
   192                              <3> ; uu.asm
   193                              <3>  extern reg_edx
   194                              <3> 
   195                              <3> ; uu.asm
   196                              <3>  extern MN_BSWAP, MN_O32
   197                              <3> 
   198                              <3> ; uu.asm
   199                              <3>  extern MN_A32
   200                              <3> 
   201                              <3> ; amis.asm
   202                              <3>  extern amisintr_offset, deviceshim_size, ext_amis_handler
   203                              <3> 
   204                              <3> ; boot.asm
   205                              <3>  extern boot_remember_seek_handle
   206                              <3>  extern boot_remember_seek_offset, chkeol_or_then, cmd_goto.yy_entry
   207                              <3>  extern display_y_or_ext, ext_cmdline, ext_finish.boot
   208                              <3>  extern if_exists_found_open, if_exists_not_found
   209                              <3>  extern if_exists_then_address, iseol?_or_then, loadoptiontable
   210                              <3>  extern loadoptiontable.incompatible, loadsettings
   211                              <3>  extern msdos7_message_table, msdos7_message_table.size
   212                              <3>  extern msg.boot_access_error, msg.boot_and, msg.boot_auxbuff_crossing
   213                              <3>  extern msg.boot_badchain, msg.boot_badclusters, msg.boot_badfat
   214                              <3>  extern msg.boot_bpb_load_overlap, msg.boot_bpb_too_low
   215                              <3>  extern msg.boot_cannot_set_both, msg.boot_dot_crlf
   216                              <3>  extern msg.boot_file_not_found, msg.boot_file_too_big_error
   217                              <3>  extern msg.boot_file_too_small_error, msg.boot_internal_error
   218                              <3>  extern msg.boot_invalid_filename, msg.boot_invalid_heads
   219                              <3>  extern msg.boot_invalid_sectors, msg.boot_out_of_memory_error
   220                              <3>  extern msg.boot_partition_cycle_error, msg.boot_partition_not_found
   221                              <3>  extern msg.boot_quit_fail, msg.boot_sector_not_power
   222                              <3>  extern msg.boot_sector_too_large, msg.boot_sector_too_small
   223                              <3>  extern msg.boot_segment_too_low, msg.boot_too_many_partitions_error
   224                              <3>  extern msg.bootfail, msg.bootfail_check_mismatch
   225                              <3>  extern msg.bootfail_check_mismatch.check_got
   226                              <3>  extern msg.bootfail_check_mismatch.check_offset
   227                              <3>  extern msg.bootfail_check_mismatch.check_value, msg.bootfail_code
   228                              <3>  extern msg.bootfail_read, msg.bootfail_read_errorcode
   229                              <3>  extern msg.bootfail_secsizediffer, msg.bootfail_sig
   230                              <3>  extern msg.bootfail_sig_parttable, msg.bootfail_stack_underflow
   231                              <3>  extern msg.bpb, msg.checkoffset, msg.checkvalue, msg.dir
   232                              <3>  extern msg.dirinsteadsize, msg.emptydirname, msg.entry
   233                              <3>  extern msg.guard_auxbuff_error, msg.hidden, msg.hiddenadd
   234                              <3>  extern msg.maxpara, msg.minpara, msg.protocol, msg.quit, msg.read
   235                              <3>  extern msg.sector, msg.sector_alt, msg.segment, msg.write
   236                              <3>  extern msg.yy_empty, msg.yy_filename_empty, msg.yy_no_file
   237                              <3>  extern msg.yy_requires_filename, msg.yy_too_large
   238                              <3>  extern msg.yy_too_many_handles, terminator_in_line_in.offset
   239                              <3>  extern terminator_in_line_in.value, throwret
   240                              <3>  extern yy_boot_attempt_open_pathname, yy_boot_attempt_open_stack
   241                              <3>  extern yy_is_script
   242                              <3> 
   243                              <3> ; cc.asm
   244                              <3>  extern count_var, hh.single, msg.clear, msg.clear_sequence
   245                              <3>  extern msg.range, parsecm
   246                              <3> 
   247                              <3> ; dd.asm
   248                              <3>  extern auxbuff_current_size_minus_24, charcounter
   249                              <3>  extern dstringaddr, dstringtype, firstmcb, firstumcb, intaddress
   250                              <3>  extern lastint, lastint_is_86m_and_mcb, msg.di_empty, msg.di_error
   251                              <3>  extern msg.di_freedos_reloc, msg.di_hidden, msg.di_hma, msg.di_iisp
   252                              <3>  extern msg.di_jmpfar, msg.di_jmpfarindirect, msg.di_multiplex.1
   253                              <3>  extern msg.di_multiplex.2, msg.di_multiplex.3, msg.di_nonstd_iisp
   254                              <3>  extern msg.di_system_low, msg.di_system_mcb, msg.di_system_upper
   255                              <3>  extern msg.di_testhook, msg.di_toomany, msg.di_uninst_iisp
   256                              <3>  extern msg.header, msg.header.length, msg.invmcbadr, msg.prefixes
   257                              <3>  extern msg.tableheader, msg.tableheadertop, msg.top, msg.trailer
   258                              <3>  extern msg.trailer.length, smcbmsg_unknown, smcbtypes
   259                              <3> 
   260                              <3> ; debug.asm
   261                              <3>  extern UnhookInterruptForce, UnhookInterruptForceSim, aa
   262                              <3>  extern adusetup, bb, boot_ebdaflag, boot_initcode
   263                              <3>  extern boot_new_memsizekib, boot_old_memsizekib, cc, code_start, ddd
   264                              <3>  extern device_initcode, driveno, dumpregs_extended.exit, ee
   265                              <3>  extern eld_linkcall.call_cmd3, end_of_ldebug_code, entry_int3_retf
   266                              <3>  extern errcarat, ff, get_86m_interrupt_handler_no_dos, get_columns
   267                              <3>  extern getline_close_file, getline_close_file.resetstuff, gg, hh
   268                              <3>  extern hh_depth, hh_depth_of_single_term, hhflag, ia_restore, ii
   269                              <3>  extern immasm, install_86m_interrupt_handler, int22, int2D, intr0
   270                              <3>  extern intr0C, intr0D, intr1, intr18, intr19
   271                              <3>  extern intr3, intr6, intr8, linkinfo, ll
   272                              <3>  extern ll3, ll_copy_cmdline_and_fcbs
   273                              <3>  extern ll_copy_cmdline_and_fcbs.have_cx
   274                              <3>  extern mm, msg.NULblank, msg.asmoptions_1, msg.boothelp
   275                              <3>  extern msg.build_array, msg.build_long_amount, msg.build_short_amount
   276                              <3>  extern msg.build_version_amount, msg.cannot_hook_2D.invalid
   277                              <3>  extern msg.cannot_hook_2D.nofree, msg.cannotbootquit_memsizes
   278                              <3>  extern msg.condhelp, msg.ensure_no_memory, msg.expressionhelp
   279                              <3>  extern msg.flaghelp, msg.flags_1, msg.guard_rc_error
   280                              <3>  extern msg.guard_re_error, msg.help_array, msg.help_array_amount
   281                              <3>  extern msg.help_re, msg.help_run, msg.help_source, msg.keep
   282                              <3>  extern msg.license, msg.line_out_overflow, msg.n_toolongname
   283                              <3>  extern msg.n_toolongtail, msg.nobootsupp, msg.options_array
   284                              <3>  extern msg.options_array_amount, msg.options_pages, msg.options_scan
   285                              <3>  extern msg.options_scan_amount, msg.qq_a_terminated
   286                              <3>  extern msg.qq_a_unterminated, msg.qq_device_no_c, msg.qq_device_no_d
   287                              <3>  extern msg.qq_device_none_selected, msg.qq_unterm
   288                              <3>  extern msg.rc_limit_reached, msg.re, msg.re_limit_reached
   289                              <3>  extern msg.reghelp, msg.rh_disabled, msg.rh_enabled, msg.run
   290                              <3>  extern msg.serial_cannot_hook, msg.serial_cannot_hook.new_int
   291                              <3>  extern msg.serial_cannot_hook.old_int, msg.serial_cannot_unhook
   292                              <3>  extern msg.serial_cannot_unhook.int, msg.serial_cannot_unhook.nowarn
   293                              <3>  extern msg.serial_late_unhook, msg.serial_late_unhook.int
   294                              <3>  extern msg.serial_no_keep_enter, msg.serial_no_keep_timer
   295                              <3>  extern msg.serial_request_keep, msg.source, msg.string_build
   296                              <3>  extern msg.string_options, msg.string_version
   297                              <3>  extern msg.tsr_cannot_terminate_attached, msg.varhelp, oo, ph_msg, pp
   298                              <3>  extern putrunint, putsz_exthelp, rr, run, section.DEVICESHIM.vstart
   299                              <3>  extern serial_clean_up, serial_clear_fifos, serial_eoi
   300                              <3>  extern serial_init_UART, serial_install_interrupt_handler
   301                              <3>  extern serial_interrupt_handler, serial_uninstall_interrupt_handler
   302                              <3>  extern set_irq, setscreen, sleep_delta_limit, sleep_highest_delta
   303                              <3>  extern sss, tpg_initialise_empty_auxbuff.reset
   304                              <3>  extern transfer_to_ext_puts_getline, tt, update_inttab_optional, uu
   305                              <3>  extern vv, vv_disable, vv_set, ww, yy
   306                              <3> 
   307                              <3> ; debug.asm
   308                              <3>  extern eld_linkcall
   309                              <3> 
   310                              <3> ; ee.asm
   311                              <3>  extern bufend, bufnext, fillbuf, fullbsout
   312                              <3>  extern getline_is_input_file?, line_in, linecounter, load_extension
   313                              <3>  extern msg.ext, notatty, prehak1, run2324
   314                              <3> 
   315                              <3> ; hh.asm
   316                              <3>  extern hh_div_active, hh_div_dividend, hh_div_divisor
   317                              <3>  extern msg.base, msg.group, msg.hh_div_remainder, msg.width
   318                              <3> 
   319                              <3> ; iioo.asm
   320                              <3>  extern if_exists_length, if_exists_si, if_exists_sp
   321                              <3>  extern install, msg.exists, msg.install, msg.not, msg.then
   322                              <3>  extern msg.y, resetrc, yy_or_ext_no_guard_re
   323                              <3> 
   324                              <3> ; immasm.asm
   325                              <3>  extern aa_ret, addrr, condmsg, error_mirror, index
   326                              <3>  extern msg.immasm_error_eip, presizeflags, reg32addr, segmnt
   327                              <3>  extern segrgaddr
   328                              <3> 
   329                              <3> ; msg.asm
   330                              <3>  extern ..@boot_scan_dir_return_fat16_root_entry
   331                              <3>  extern ..@boot_scan_dir_return_filenotfound
   332                              <3>  extern ..@boot_scan_dir_return_subdir_or_fat32_entry
   333                              <3>  extern alloc_size_not_reserved, asciitablenames, boot_init_foundname
   334                              <3>  extern configpath, configpath.dir_end, device_quittable_regs, dpmi32
   335                              <3>  extern execblk.cmdline, ext_command_handler, ext_finish.bp_is_set
   336                              <3>  extern ext_handle, ext_inject_handler, ext_preprocess_handler
   337                              <3>  extern ext_puts_copyoutput_handler, ext_puts_getline_handler
   338                              <3>  extern ext_puts_handler, ext_var, ext_var_amount, ext_var_format
   339                              <3>  extern ext_var_size, extcssel, extdssel, handle_scan_dir_entry
   340                              <3>  extern handle_scan_dir_not_found, history.first, history.last
   341                              <3>  extern indirect_array_errfix, init_executable_pathname
   342                              <3>  extern init_executable_pathname.end, internalflags4, internalflags5
   343                              <3>  extern internalflags7, isvariable_morebyte_nameheaders.ext
   344                              <3>  extern lastcmd_transfer_ext_address, lastcmd_transfer_ext_entry
   345                              <3>  extern line_in.end, linkcall_table, load_adr_dirbuf_segment
   346                              <3>  extern load_check_dir_attr, load_data_lowest, load_kernel_name
   347                              <3>  extern load_yy_direntry, load_yyname_input, load_yyname_next
   348                              <3>  extern near_transfer_ext_address, near_transfer_ext_entry
   349                              <3>  extern next_reserved_segment, options4, options5, options7
   350                              <3>  extern patcharea_intrtn, patcharea_intrtn.segment
   351                              <3>  extern patcharea_intrtn.size, patcharea_run, patcharea_run.segment
   352                              <3>  extern patcharea_run.size, pm_2_86m_0, promptlen, reserved_address
   353                              <3>  extern scriptspath, scriptspath.dir_end
   354                              <3>  extern sss_silent_count, sss_silent_count_used, stack_end, swch1
   355                              <3>  extern while_buffer.end
   356                              <3> 
   357                              <3> ; msg.asm
   358                              <3>  extern install_trying
   359                              <3> 
   360                              <3> ; init.asm
   361                              <3>  extern ..@init_behind, ..@init_first
   362                              <3>  extern ..@patch_no386_ds_6_DATA_ENTRY
   363                              <3>  extern ..@patch_no386_ds_code_or_entry
   364                              <3>  extern ..@patch_no386_iret_code_or_entry, behind_code_truncated
   365                              <3>  extern behind_init, behind_messagesegment_nobits
   366                              <3>  extern behind_messagesegment_nobits_truncated, debug22
   367                              <3>  extern device_header.next, devint23, devint24, entry_retf
   368                              <3>  extern execblk.fcb1, execblk.fcb2, ext_data_area, extcall_table.ret
   369                              <3>  extern extcall_table.segsel, fileext, hVdd, immasm_buffer, initcont
   370                              <3>  extern initcont.boot_entry, initcont.device, inttab, inttab.i06
   371                              <3>  extern inttab.i2D, inttab_number_variable, line_out_overflow
   372                              <3>  extern linkcall_table.code1, linkcall_table.entry
   373                              <3>  extern linkcall_table.init, oldmode, pInDOS, pSDA, regs.size
   374                              <3>  extern switchar, trim_overflow, var_addr_entries
   375                              <3>  extern var_addr_entries.amount
   376                              <3> 
   377                              <3> ; install.asm
   378                              <3>  extern installflags, msg.alreadydisabled
   379                              <3>  extern msg.alreadyenabled, msg.toggle, msg.trydisable, msg.tryenable
   380                              <3> 
   381                              <3> ; ints.asm
   382                              <3>  extern debuggeramissig, inttab_optional
   383                              <3> 
   384                              <3> ; lineio.asm
   385                              <3>  extern auxbuff_amount_silent, cmd3_set_options
   386                              <3>  extern determine_quiet_output, eldheader, getc_repeat_idle
   387                              <3>  extern getline_timer_func, handle_ctrl_c, if_exists_found_closed
   388                              <3>  extern if_exists_found_ext_open, indos_remember_seek_function
   389                              <3>  extern indos_remember_seek_handle, indos_remember_seek_offset
   390                              <3>  extern input_file_handles.to_close, msg.configkeyword
   391                              <3>  extern msg.eld_error_code, msg.eld_load_error, msg.emptykeyword
   392                              <3>  extern msg.eof, msg.executablekeyword, msg.ext_error_internal
   393                              <3>  extern msg.ext_error_invalid, msg.ext_error_io, msg.ext_error_oom
   394                              <3>  extern msg.freedos_ctrlc_workaround, msg.goto_empty
   395                              <3>  extern msg.goto_not_file, msg.goto_not_found.1, msg.goto_not_found.2
   396                              <3>  extern msg.history_internal_error, msg.more, msg.more_over
   397                              <3>  extern msg.more_over_size, msg.more_size, msg.rh_step.1
   398                              <3>  extern msg.rh_step.2, msg.scriptskeyword, msg.silent_error, msg.sof
   399                              <3>  extern msg.unexpected_noneol_rc, msg.unexpected_noneol_re
   400                              <3>  extern msg.yy_error_file_open, msg.yy_filename_missing_unquote
   401                              <3>  extern msg.yy_no_dos, qq, section.DATASTACK.vstart
   402                              <3>  extern serial_check_receive_char, serial_receive_char
   403                              <3>  extern serial_send_char, skip_rh, yy_boot
   404                              <3>  extern yy_boot_clear_remember_seek, yy_boot_close_file, yy_boot_read
   405                              <3>  extern yy_boot_remember_seek, yy_boot_seek_current
   406                              <3>  extern yy_boot_seek_start, yy_try_scriptspath
   407                              <3>  extern yy_try_scriptspath.didnotyettry
   408                              <3>  extern yy_try_scriptspath.nokeywordused
   409                              <3> 
   410                              <3> ; ll.asm
   411                              <3>  extern doserr8, ensuredebuggeeloaded, execblk, execblk.csip
   412                              <3>  extern execblk.sssp, msg.hexerror, msg.ll_unterm, msg.not_while_indos
   413                              <3>  extern msg.tsr_cannot_ll, parselw, reading
   414                              <3>  extern terminate_attached_process, ww1, ww15, zeroregs
   415                              <3> 
   416                              <3> ; mm.asm
   417                              <3>  extern has_287, has_copr, msg.c0, msg.cr, msg8088
   418                              <3>  extern msgx86, no_copr, parsecm_have_address
   419                              <3> 
   420                              <3> ; serialp.asm
   421                              <3>  extern baseport, msg.no_progress, rxfifo, rxhead
   422                              <3>  extern rxtail, serial_fcr_setting, serial_installed_intnum
   423                              <3>  extern serial_save_dl, serial_save_ier, serial_save_irq_mask
   424                              <3>  extern serial_save_irq_off, serial_save_lcr, serial_save_mcr, txfifo
   425                              <3>  extern txhead, txtail
   426                              <3> 
   427                              <3> ; ss.asm
   428                              <3>  extern msg.matches, msg.reverse, msg.seconds, msg.sleep
   429                              <3>  extern msg.ticks, sleep_repeat_idle
   430                              <3> 
   431                              <3> ; vv.asm
   432                              <3>  extern csrpos, msg.nokeep, msg.off, msg.on, msg.vv_disabled
   433                              <3>  extern msg.vv_enable_failure, xmsdrv, xmsmove
   434                              <3> 
   435                              <3> ; ww.asm
   436                              <3>  extern diskful, doserr11, doserr2, doserr3, doserr5
   437                              <3>  extern drive, drivenumber, dskerrs, not_while_indos, nowhexe
   438                              <3>  extern nownull, openerr, openerr1, writing, wwmsg1
   439                              <3>  extern wwmsg2
   440                              <3> 
   441                              <3> 
   442                              <3>  extern bCSAttr, lDEBUG_CODE_to_lDEBUG_CODE2_nearcall_helper
   443                              <3> 
   444                              <3>  extern hook2F.not_in_dos
   445                              <3> 
   446                              <3>  extern cmd4.int3, lDEBUG_CODE2_dualret_helper
   447                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_nearcall_helper
   448                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE2_dualcall_helper, msg.bu
   449                              <3>  extern msg.bu_relocated, msg.bu_relocated.sign
   450                              <3> 
   451                              <3>  extern nopmsupp
   452                              <3> 
   453                              <3>  extern bAddr32
   454                              <3> 
   455                              <3>  extern descriptor, descriptor.attrib, descriptor.base
   456                              <3>  extern descriptor.limit, gatewrong, msg.d.a_error, msg.d.a_error_code
   457                              <3>  extern msg.d.a_success, msg.d.a_success_sel, msg.d.b_error
   458                              <3>  extern msg.d.b_error_code, msg.d.b_success, msg.d.d_error
   459                              <3>  extern msg.d.d_error_code, msg.d.d_success, msg.d.l_error
   460                              <3>  extern msg.d.l_error_code, msg.d.l_success, msg.d.t_error
   461                              <3>  extern msg.d.t_error_code, msg.d.t_success, msg.deschelp, msg.ofs32
   462                              <3>  extern nodesc
   463                              <3> 
   464                              <3>  extern ..@patch_tsr_quit_run, areastruc_entry.qq_entry, cssel
   465                              <3>  extern ddebugareas.next, debug2F, dpmidisable, dpmientry, dpmihook
   466                              <3>  extern dpmihookamis, dpmihookcs, dpmiwatch, end_of_ldebug_code2
   467                              <3>  extern findinstalleddebugger, get_messagesegsel, handle_mode_changed
   468                              <3>  extern i23pm, msg.cannotpmquit, msg.desc, msg.dpmi_no_hook, msg.msdos
   469                              <3>  extern msg.qq_device_pm, msg.qq_still_pm, msg.qqlate_areas_error
   470                              <3>  extern msg.readonly_verifysegm, msg.readonly_verifysegm.selector
   471                              <3>  extern mydpmientry, nodosext, oldi2F, pm_reset_handlers, scratchsel
   472                              <3>  extern sr_state, switchmode, uninstall_areas.qq_entry
   473                              <3> 
   474                              <3>  extern i24pm
   475                              <3> 
   476                              <3>  extern auxbuff_switchbuffer_size, code2_seg, code2_sel, code2_size
   477                              <3>  extern code_sel, daresult, dssel, immsel
   478                              <3>  extern lDEBUG_CODE2_to_lDEBUG_CODE_dualcall_helper
   479                              <3>  extern lDEBUG_CODE_dualret_helper, messagesel, msg.desctype
   480                              <3>  extern msg.stack_overflow.desctype
   481                              <3> 
   482                              <3>  extern cmd3_mirror
   483                              <3> 
   484                              <3>  extern ..@patch_entry_seg, ..@patch_no386_ds_4, ..@patch_no386_ds_5
   485                              <3>  extern ..@patch_no386_ds_entry_pmint21_1
   486                              <3>  extern ..@patch_no386_ds_entry_pmint21_2, areas_fun, areas_sub
   487                              <3>  extern ddebugareas.prev, linkcall_table.code2
   488                              <3> 
   489                              <3>  extern areas_struc, msg.areasalreadyinstalled
   490                              <3>  extern msg.areasalreadyuninstalled, msg.areasinstalled
   491                              <3>  extern msg.areasnodebuggerfound, msg.areasnotinstalled
   492                              <3>  extern msg.areasnotinstalled.code, msg.areasnotsupported
   493                              <3>  extern msg.areasuninstalled, msg.areasuninstalled.code
   494                              <3> 
   495                              <3>  extern intcall_return_parameter_es_parameter_ds
   496                              <3>  extern lDEBUG_CODE_to_lDEBUG_CODE_dualcall_helper, pop_if, push_if
   497                              <3> 
   498                              <3>  extern isextenderavailable, msg.cannotpmload, nodosextinst
   499                              <3> 
   500                              <3>  extern install_areas, patcharea_pm_exc, patcharea_pm_exc.segment
   501                              <3>  extern patcharea_pm_exc.size
   502                              <3> 
   503                              <3>  extern pmint21
   504                              <3> 
   505                              <3>  extern debuggerexception, entry_to_code_sel, exc6msg, excCmsg
   506                              <3>  extern excDmsg, excEmsg, intrtn2_entry, pmintsave.int21
   507                              <3> 
   508                              <3>  extern convsegs, convsegs.amount_fixed, convsegs.end_fixed
   509                              <3>  extern dpmi_pm2rm, dpmi_pmsav, dpmi_rm2pm, dpmi_rmsav, endexctab
   510                              <3>  extern exc_first, exc_second, excsave, exctab, installdpmimsg
   511                              <3>  extern intrtn_entry.from_installdpmi, pmintsave, pminttab
   512                              <3>  extern pminttab.end, setrmaddr, silence_delete_one_string.internal
   513                              <3> 
   514                              <3>  extern msg.rv_mode_dpmi_16, msg.rv_mode_dpmi_32, msg.vm_code2seg
   515                              <3>  extern msg.vm_selector, msg.vp_dpspsel, msg.vp_pspsel, psp_selector
   516                              <3> 
   517                              <3>  extern ..@getcseipbyte_fault_skip_6_near_call
   518                              <3>  extern ..@hh_code1_indirection_memory_access_end
   519                              <3>  extern ..@hh_code1_indirection_memory_access_start
   520                              <3>  extern ..@readmem_fault_skip_2_near_call
   521                              <3>  extern ..@setcseipbyte_fault_skip_6_near_call
   522                              <3>  extern ..@writemem_fault_skip_2_near_call_a
   523                              <3>  extern ..@writemem_fault_skip_2_near_call_b, behind_code
   524                              <3>  extern behind_code2, convsegs.amount, ddebugareas
   525                              <3>  extern getline_extra_int22.cleartraceflag, msg.list_bp_cseip_32
   526                              <3> 
   527                              <3>  extern MN_O16
   528                              <3> 
   529                              <3>  extern MN_A16
   530                              <3> 
   531                              <3>  extern relocatedzero
   532                              <3> 
   533                              <3>  extern msg.bu_disabled
   534                              <3> 
   535                              <3>  extern reset_interrupts, set_interrupts
   536                              <3> 
   537                              <3>  extern startoptions6
   538                              <3> 
   539                              <3>  extern currentposition, msg.loader_bottom_not_allowed
   540                              <3>  extern msg.loader_too_low_load
   541                              <3> 
   542                              <3>  extern intr_loader_18, intr_loader_19, moveloader_hook_ints
   543                              <3> 
   544                              <3>  extern loader_query, loader_transfer_cmd3, loader_transfer_relocate
   545                              <3> 
   546                              <3>  extern cmd3_int_disable.set_bx_to_dx, cmd3_int_enable.set_bx_to_dx
   547                              <3>  extern ldebug_code_size, movesegrefstable, movetable
   548                              <3>  extern movetable.bottom, msg.isalready, msg.isnow, msg.loader_error
   549                              <3>  extern msg.move, msg.move_auxbuff_error, msg.move_auxdown
   550                              <3>  extern msg.move_auxup, msg.move_ebdanottop, msg.move_empty
   551                              <3>  extern msg.move_int_error, msg.move_int_panic
   552                              <3>  extern msg.move_must_be_bottom, msg.move_nottop, msg.move_oom
   553                              <3>  extern msg.move_rpl, msg.move_toolargeebda, msg.unsupportedmove
   554                              <3>  extern qq_int_unhook_sim.set_bx_to_dx
   555                              <3> 
   556                              <3>  extern moveloader.already, moveloader.bottom_to_hidden
   557                              <3>  extern moveloader.bottom_to_top, moveloader.hidden_to_bottom
   558                              <3>  extern moveloader.hidden_to_top, moveloader.top_to_bottom
   559                              <3>  extern moveloader.top_to_hidden
   560                              <3> 
   561                              <3>  extern moveloader.specificerror, moveloader_check_serial, msg.godebug
   562                              <3>  extern msg.loader_extra, msg.loader_flag, msg.loader_loadseg_low
   563                              <3>  extern msg.loader_must_be_hidden, msg.loader_sign, msg.loader_stack
   564                              <3>  extern msg.loadsupportsignature, msg.loadsupportsignature.size
   565                              <3> 
   566                              <3>  extern depack, hshrink_memory_source.offset
   567                              <3>  extern hshrink_memory_source.segment, indirect_hshrink_message_buffer
   568                              <3>  extern msg.hshrink_error, nontruncated_hshrink_message_buffer
   569                              <3> 
   570                              <3>  extern truncated_hshrink_message_buffer
   571                              <3> 
   572                              <3>  extern patch_boothelp_uncompressed
   295                              <2> %endif
   710                              <1> %endif
   711                              <1> [list -]
   714                              <1> 
   715                              <1> %include "eld.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> Extensions for lDebug macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> %ifndef ELD_MAC
    16                              <2> %define ELD_MAC 1
    17                              <2> 
    18                              <2> %include "lmacros3.mac"
     1                              <3> [list -]
    19                              <2> 
    20                              <2> 		; ELD executable header
    21                              <2> 	struc ELD_HEADER
    22 00000000 ????????            <2> eldhSignature:		resb 4	; "ELD1"
    23 00000004 ??????              <2> 			resb 3	; reserved
    24 00000007 ??                  <2> 			resb 1	; 26 (Ctrl-Z)
    25 00000008 ????????            <2> eldhCodeOffset:		resd 1	; position displacement from eldhSignature
    26 0000000C ????                <2> eldhCodeImageLength:	resw 1	; amount bytes, at least 32
    27 0000000E ????                <2> eldhCodeAllocLength:	resw 1	; amount bytes, added to prior. sum < 64 KiB
    28 00000010 ????????            <2> eldhDataOffset:		resd 1
    29 00000014 ????                <2> eldhDataImageLength:	resw 1	; (zero allowed)
    30 00000016 ????                <2> eldhDataAllocLength:	resw 1	; (zero allowed)
    31 00000018 ????                <2> eldhCodeEntrypoint:	resw 1	; within code section, used as displacement
    32 0000001A ????????            <2> eldhReserved:		resb 4	; reserved
    33 0000001E ????                <2> eldhExtensionSize:	resw 1	; from eldhSignature, -> past eldhx fields in use
    34                              <2> 	endstruc
    35                              <2> 	endarea ELD_HEADER, 1
    36                              <2> 
    37                              <2> 	struc ELD_HEADERX
    38 00000000 <res 20h>           <2> eldhxHeader:		resb ELD_HEADER_size
    39 00000020 ????????            <2> eldhxDescriptionOffset:	resd 1	; zero if none, from eldhxHeader. <= 128 Bytes
    40 00000024 ????????            <2> eldhxHelpOffset:	resd 1	; zero if none, from eldhxHeader
    41 00000028 ????????            <2> eldhxLibTable:		resd 1	; zero if none, from eldhxHeader
    42 0000002C ????????            <2> eldhxDateTimeOffset:	resd 1	; zero if none, from eldhxHeader
    43                              <2> 	alignb 16
    44                              <2> 	endstruc
    45                              <2> 
    46                              <2> 	struc ELD_TRAILER_HEADER
    47 00000000 ????????????????    <2> eldthSignature:		resb 8	; "ELD1TAIL"
    48 00000008 ????????            <2> eldthHeaderOffset:	resd 1	; negative displacement from eldthSignature,
    49                              <2> 				;  add this dword to the seek offset
    50 0000000C ????                <2> eldthReserved:		resw 1	; reserved, must be initialised to zero
    51 0000000E ????                <2> eldthChecksum:		resw 1	; sum of all words in trailer header = 0
    52                              <2> 	endstruc
    53                              <2> 	endarea ELD_TRAILER_HEADER, 1
    54                              <2> 
    55                              <2> 	struc ELD_LIBTABLE
    56 00000000 ????                <2> eldltFormat:		resw 1
    57                              <2> 	; 0 = uncompressed
    58                              <2> 	; 2 = heatshrink compressed
    59                              <2> 	; 3 = lzexedat -4 compressed
    60                              <2> 	; 4 = lzexedat -4 -l compressed
    61 00000002 ????                <2> eldltAmount:		resw 1
    62 00000004 ????????            <2> eldltOffset:		resd 1	; from eldhxHeader
    63                              <2> eldltCompressedLength:		; (dword, only present if format 2, 3, or 4)
    64                              <2> 	endstruc
    65                              <2> 	endarea ELD_LIBTABLE, 1
    66                              <2> 
    67                              <2> 		; ELD instance header
    68                              <2> 	struc ELD_INSTANCE
    69 00000000 ????                <2> eldiStartCode:		resw 1	; -> this structure itself (para aligned)
    70 00000002 ????                <2> eldiEndCode:		resw 1	; -> behind memory used by instance (para aligned)
    71 00000004 ????                <2> eldiStartData:		resw 1	; -> data in data entry section (para aligned), or 0
    72 00000006 ????                <2> eldiEndData:		resw 1	; -> behind data (para aligned), or 0
    73 00000008 ????????????????    <2> eldiIdentifier:		resb 8	; blank-filled text
    74 00000010 ????                <2> eldiFlags:		resw 1	; flags
    75                              <2> eldiListing_size equ 14
    76 00000012 <res Eh>            <2> eldiListing:		resb eldiListing_size
    77                              <2> 				; ASCIZ listing file name
    78                              <2> 	endstruc
    79                              <2> 		; flags for eldiFlags:
    80                              <2> eldifResident:		equ 1
    81                              <2> 
    82                              <2> 		; ELD link info header
    83                              <2> 	struc ELD_LINKINFO
    84 00000000 ????                <2> eldlSignature:		resw 1	; 0E1D1h
    85 00000002 ????????            <2> eldlReserved:		resw 2
    86 00000006 ????                <2> eldlUseLinkHash:	resw 1
    87 00000008 ????                <2> eldlDataAmount:		resw 1
    88 0000000A ????                <2> eldlDataPrefixes:	resw 1
    89 0000000C ????                <2> eldlDataEntries:	resw 1
    90 0000000E ????                <2> eldlDataAddresses:	resw 1
    91 00000010 ????                <2> eldlCodeAmount:		resw 1
    92 00000012 ????                <2> eldlCodePrefixes:	resw 1
    93 00000014 ????                <2> eldlCodeEntries:	resw 1
    94 00000016 ????                <2> eldlCodeAddresses:	resw 1
    95                              <2> 	endstruc
    96                              <2> 
    97                              <2> 	numdef ELD_CODE_VSTART, 9001h
    98                              <2> 	numdef ELD_DATA_VSTART, 8000h
    99                              <2> 	numdef ELD_RELOC_VSTART, 8000h
   100                              <2> 
   101                              <2> 	numdef ELD_RECLAIM_HINT, 0
   102                              <2> 	strdef ELD_LISTING, ""
   103                              <2> 	numdef ELD_DATETIME, 0
   104                              <2> 
   105                              <2> %if _ELD_DATETIME
   106                              <2>  %define PUT_ELDHX_DATETIME_OFFSET at eldhxDateTimeOffset, dd DATAOFFSET + datetime - datastart
   107                              <2>  %macro PUT_ELD_DATETIME 0.nolist
   108                              <2> datetime:	asciz __UTC_DATE__,'T',__UTC_TIME__,'Z'
   109                              <2> 		asciz		; for future extension
   110                              <2>  %endmacro
   111                              <2> %else
   112                              <2>  %define PUT_ELDHX_DATETIME_OFFSET
   113                              <2>  %define PUT_ELD_DATETIME
   114                              <2> %endif
   115                              <2> 
   116                              <2> %endif
   716                              <1> 
   717                              <1> %include "install.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug INSTALL command macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2023 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	struc INSTALLFLAG
    17 00000000 ????                <2> ifKeyword:	resw 1
    18 00000002 ????                <2> ifDescription:	resw 1
    19 00000004 ????                <2> ifOptions:	resw 1
    20 00000006 ????                <2> ifValue:	resw 1
    21 00000008 ????                <2> ifTrying:	resw 1
    22 0000000A ????                <2> ifReserved:	resw 1
    23                              <2> 	endstruc
    24                              <2> 
   718                              <1> 
   719                              <1> %if _SYMBOLIC
   720                              <1> 	defaulting 0			; disable defaulting
   721                              <1> %include "symbols.mac"
   722                              <1> [list -]
   723                              <1> 		; symbolic branch defines *without* defaulting!
   724                              <1> 	numdef ZZ_INSERT_TEMP, 1
   725                              <1> 	numdef XMS_SYMBOL_TABLE, 1
   726                              <1> 	numdef BUFFER_86MM_SLICE, 0
   727                              <1> 	numdef SECOND_SLICE, 0
   728                              <1> 
   729                              <1> 	defaulting 1			; re-enable defaulting
   730                              <1> 
   731                              <1> 		; symbolic branch defines
   732                              <1> 	numdef 86MM_SYMBOL_TABLE_MAX, 256, 256
   733                              <1> %endif
   734                              <1> 
   735                              <1> 	struc SEGADR
   736 00000000 ????????            <1> saOffset:	resd 1
   737 00000004 ????                <1> saSegSel:	resw 1
   738                              <1> %if _PM
   739                              <1> saSegment:	resw 1
   740                              <1> saSelector:	resw 1
   741                              <1> %endif
   742                              <1> 	endstruc
   743                              <1> 
   744                              <1> 	%macro segmentedaddress 0.nolist
   745                              <1> 	istruc SEGADR
   746                              <1> 	iend
   747                              <1> 	%endmacro
   748                              <1> 
   749                              <1> 	struc SEGOFS16ADR
   750 00000000 ????                <1> so16aOffset:	resw 1
   751 00000002 ????                <1> so16aSegSel:	resw 1
   752                              <1> %if _PM
   753                              <1> so16aSegment:	resw 1
   754                              <1> so16aSelector:	resw 1
   755                              <1> %endif
   756                              <1> 	endstruc
   757                              <1> 
   758                              <1> 	%macro segofs16address 0-1.nolist zero
   759                              <1> 	istruc SEGOFS16ADR
   760                              <1> %ifidni %1,zero
   761                              <1> %elifidni %1,minusone
   762                              <1> at so16aOffset,		dw -1
   763                              <1> at so16aSegSel,		dw -1
   764                              <1>  %if _PM
   765                              <1> at so16aSegment,	dw -1
   766                              <1> at so16aSelector,	dw -1
   767                              <1>  %endif
   768                              <1> %else
   769                              <1>  %error Unexpected initialiser keyword
   770                              <1> %endif
   771                              <1> 	iend
   772                              <1> 	%endmacro
   773                              <1> 
   774                              <1> 	struc SEGONLYADR
   775 00000000 ????                <1> soaSegSel:	resw 1
   776                              <1> %if _PM
   777                              <1> soaSegment:	resw 1
   778                              <1> soaSelector:	resw 1
   779                              <1> %endif
   780                              <1> 	endstruc
   781                              <1> 
   782                              <1> 	%macro segonlyaddress 0.nolist
   783                              <1> 	istruc SEGONLYADR
   784                              <1> 	iend
   785                              <1> 	%endmacro
   786                              <1> 
   787                              <1> 
   788                              <1> %if _LOADER
   789                              <1> 	struc MOVETABLEENTRY
   790                              <1> mteIdentifier:		resw 1
   791                              <1> mteArrayIndex:		resw 1
   792                              <1> mteStatusMessage:	resw 1
   793                              <1> mteFromArray:
   794                              <1> mteFromBottom:		resw 1
   795                              <1> mteFromTop:		resw 1
   796                              <1> mteFromHidden:		resw 1
   797                              <1> 	endstruc
   798                              <1> %endif
   799                              <1> 
   800                              <1> %if _BOOTLDR
   801                              <1>  %include "iniload.mac"
     1                              <2> %if 0
     2                              <2> 
     3                              <2> lDebug iniload/boot interfacing structs and macros
     4                              <2> 
     5                              <2> Copyright (C) 2008-2025 E. C. Masloch
     6                              <2> 
     7                              <2> Usage of the works is permitted provided that this
     8                              <2> instrument is retained with the works, so that any entity
     9                              <2> that uses the works is notified of this instrument.
    10                              <2> 
    11                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    12                              <2> 
    13                              <2> %endif
    14                              <2> 
    15                              <2> 
    16                              <2> 	struc BS
    17 00000000 ??????              <2> bsJump:	resb 3
    18 00000003 ????????????????    <2> bsOEM:	resb 8
    19                              <2> bsBPB:
    20                              <2> 	endstruc
    21                              <2> 
    22                              <2> 	struc EBPB		;        BPB sec
    23 00000000 ????                <2> bpbBytesPerSector:	resw 1	; offset 00h 0Bh
    24 00000002 ??                  <2> bpbSectorsPerCluster:	resb 1	; offset 02h 0Dh
    25 00000003 ????                <2> bpbReservedSectors:	resw 1	; offset 03h 0Eh
    26 00000005 ??                  <2> bpbNumFATs:		resb 1	; offset 05h 10h
    27 00000006 ????                <2> bpbNumRootDirEnts:	resw 1	; offset 06h 11h -- 0 for FAT32
    28 00000008 ????                <2> bpbTotalSectors:	resw 1	; offset 08h 13h
    29 0000000A ??                  <2> bpbMediaID:		resb 1	; offset 0Ah 15h
    30 0000000B ????                <2> bpbSectorsPerFAT:	resw 1	; offset 0Bh 16h -- 0 for FAT32
    31 0000000D ????                <2> bpbCHSSectors:		resw 1	; offset 0Dh 18h
    32 0000000F ????                <2> bpbCHSHeads:		resw 1	; offset 0Fh 1Ah
    33 00000011 ????????            <2> bpbHiddenSectors:	resd 1	; offset 11h 1Ch
    34 00000015 ????????            <2> bpbTotalSectorsLarge:	resd 1	; offset 15h 20h
    35                              <2> bpbNew:				; offset 19h 24h
    36                              <2> 
    37 00000019 ????????            <2> ebpbSectorsPerFATLarge:	resd 1	; offset 19h 24h
    38 0000001D ????                <2> ebpbFSFlags:		resw 1	; offset 1Dh 28h
    39 0000001F ????                <2> ebpbFSVersion:		resw 1	; offset 1Fh 2Ah
    40 00000021 ????????            <2> ebpbRootCluster:	resd 1	; offset 21h 2Ch
    41 00000025 ????                <2> ebpbFSINFOSector:	resw 1	; offset 25h 30h
    42 00000027 ????                <2> ebpbBackupSector:	resw 1	; offset 27h 32h
    43 00000029 <res Ch>            <2> ebpbReserved:		resb 12	; offset 29h 34h
    44                              <2> ebpbNew:			; offset 35h 40h
    45                              <2> 	endstruc
    46                              <2> 
    47                              <2> 	struc BPBN		; ofs B16 S16 B32 S32
    48 00000000 ??                  <2> bpbnBootUnit:		resb 1	; 00h 19h 24h 35h 40h
    49 00000001 ??                  <2> 			resb 1	; 01h 1Ah 25h 36h 41h
    50 00000002 ??                  <2> bpbnExtBPBSignature:	resb 1	; 02h 1Bh 26h 37h 42h -- 29h for valid BPBN
    51 00000003 ????????            <2> bpbnSerialNumber:	resd 1	; 03h 1Ch 27h 38h 43h
    52 00000007 <res Bh>            <2> bpbnVolumeLabel:	resb 11	; 07h 20h 2Bh 3Ch 47h
    53 00000012 ????????????????    <2> bpbnFilesystemID:	resb 8	; 12h 2Bh 36h 47h 52h
    54                              <2> 	endstruc		; 1Ah 33h 3Eh 4Fh 5Ah
    55                              <2> 
    56                              <2> 	struc DIRENTRY
    57 00000000 ????????????????    <2> deName:		resb 8
    58 00000008 ??????              <2> deExt:		resb 3
    59 0000000B ??                  <2> deAttrib:	resb 1
    60 0000000C ??                  <2> dePlusSize:	resb 1
    61 0000000D ??????????????      <2> 		resb 7
    62 00000014 ????                <2> deClusterHigh:	resw 1
    63 00000016 ????                <2> deTime:		resw 1
    64 00000018 ????                <2> deDate:		resw 1
    65 0000001A ????                <2> deClusterLow:	resw 1
    66 0000001C ????????            <2> deSize:		resd 1
    67                              <2> 	endstruc
    68                              <2> 
    69                              <2> ATTR_READONLY	equ 1
    70                              <2> ATTR_HIDDEN	equ 2
    71                              <2> ATTR_SYSTEM	equ 4
    72                              <2> ATTR_VOLLABEL	equ 8
    73                              <2> ATTR_DIRECTORY	equ 10h
    74                              <2> ATTR_ARCHIVE	equ 20h
    75                              <2> 
    76                              <2> lsvclSignature		equ "CL"
    77                              <2> lsvclBufferLength	equ 256
    78                              <2> 
    79                              <2> 	struc LOADSTACKVARS, -10h
    80 FFFFFFF0 ????????            <2> lsvFirstCluster:	resd 1
    81 FFFFFFF4 ????????            <2> lsvFATSector:		resd 1
    82 FFFFFFF8 ????                <2> lsvFATSeg:		resw 1
    83 FFFFFFFA ????                <2> lsvLoadSeg:		resw 1
    84 FFFFFFFC ????????            <2> lsvDataStart:		resd 1
    85                              <2> 	endstruc
    86                              <2> 
    87                              <2> 	struc LOADDATA, LOADSTACKVARS - 10h
    88 FFFFFFE0 ????                <2> ldMemoryTop:	resw 1
    89 FFFFFFE2 ????                <2> ldLoadTop:	resw 1
    90 FFFFFFE4 ????                <2> ldSectorSeg:	resw 1
    91 FFFFFFE6 ??                  <2> ldFATType:	resb 1
    92                              <2> ldFlags:
    93 FFFFFFE7 ??                  <2> ldHasLBA:	resb 1
    94 FFFFFFE8 ????                <2> ldClusterSize:	resw 1
    95 FFFFFFEA ????                <2> ldParaPerSector:resw 1
    96                              <2> ldDirCluster:			; dword
    97                              <2> ldLoadingSeg:		; word
    98                              <2> ldQueryPatchValue:	; word
    99                              <2> lsvCommandLine:		; word
   100                              <2> .start:		equ $ - lsvclBufferLength
   101 FFFFFFEC ????                <2> .signature:	resw 1
   102                              <2> ldLoadUntilSeg:		; word
   103                              <2> lsvExtra:		; word
   104 FFFFFFEE ??                  <2> .partition:	resb 1	; byte
   105 FFFFFFEF ??                  <2> .flags:		resb 1	; byte
   106                              <2> 	endstruc
   107                              <2> 
   108                              <2> ldhlfPreserveLoader	equ 4
   109                              <2> 
   110                              <2> lsvefNoDataStart	equ 1
   111                              <2> lsvefPartitionNumber	equ 2
   112                              <2> lsvefPreserveLoader	equ 4
   113                              <2> 
   114                              <2> %if lsvefPreserveLoader != ldhlfPreserveLoader
   115                              <2>  %error Unexpected flag values
   116                              <2> %endif
   117                              <2> 
   118                              <2> 	struc LOADCMDLINE, LOADDATA - lsvclBufferLength
   119                              <2> ldCommandLine:
   120 FFFFFEE0 <res 100h>          <2> .start:		resb lsvclBufferLength
   121                              <2> 	endstruc
   122                              <2> 
   123                              <2> ldfHasLBA:	equ 1
   124                              <2> ldfFATInvalid:	equ 2
   125                              <2> ldfFATBuffered:	equ 4
   126                              <2> ldfDataBuffered: equ 8
   127                              <2> 
   128                              <2> 	struc LOADDATA2, LOADDATA - 10h
   129 FFFFFFD0 ????????            <2> ldRootSector:		resd 1
   130 FFFFFFD4 ????                <2> ldEntriesPerSector:	resw 1
   131                              <2> ldDataSegment:		; word
   132 FFFFFFD6 ????                <2> ldLastAvailableSector:	resw 1
   133                              <2> ldDataSector:		; dword
   134 FFFFFFD8 ????                <2> ldParasLeft:		resw 1
   135 FFFFFFDA ????                <2> ldParasDone:		resw 1
   136                              <2> 	endstruc
   137                              <2> 
   138                              <2> 	struc LOADDATA3, LOADDATA2 - 10h
   139 FFFFFFC0 ????????            <2> ldMaxCluster:		resd 1
   140 FFFFFFC4 ????????            <2> ldFileSize:		resd 1
   141 FFFFFFC8 ????????            <2> ldCurrentCluster:	resd 1
   142 FFFFFFCC ????????            <2> ldCurrentSeek:		resd 1
   143                              <2> 	endstruc
   144                              <2> 
   145                              <2> 	struc LOADERIMAGEIDENT
   146 00000000 ????????            <2> liiSignature:		resb 4		; "NLDR"
   147 00000004 ????                <2> liiVersion:		resb 2		; "00"
   148 00000006 ????                <2> liiChecksum:		resw 1		; word sum of first 8 words = 0
   149 00000008 ????                <2> liiAmountParagraphs:	resw 1
   150 0000000A ????????????        <2> liiReserved:		resw 3
   151 00000010 ????                <2> liiEntryQuerySize:	resw 1		; 0 if not supported
   152                              <2> 		; INP:	cs => NLDR image ident
   153                              <2> 		;	ip = this word field content
   154                              <2> 		;	ax = 60h
   155                              <2> 		; OUT:	ax => behind memory requested (should be >= 60h)
   156                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   157                              <2> 		; STT:	far called, UP, EI
   158 00000012 ????                <2> liiEntryRelocate:	resw 1		; 0 if not supported
   159                              <2> 		; INP:	cs => NLDR image ident
   160                              <2> 		;	ip = this word field content
   161                              <2> 		;	ax = 60h
   162                              <2> 		; OUT:	ax => relocated NLDR segment (usually 60h)
   163                              <2> 		; CHG:	es, ds, di, si, bx, cx, dx
   164                              <2> 		; STT:	far called, UP, EI
   165 00000014 ????                <2> liiEntryDebug:		resw 1		; 0 if not supported
   166                              <2> 		; INP:	es = ds = cs = ss => relocated NLDR
   167                              <2> 		;	ip = this word field content
   168                              <2> 		;	sp = next word field content
   169                              <2> 		; STT:	running as debuggee, UP, EI
   170 00000016 ????                <2> liiStackPointer:	resw 1
   171                              <2> 	endstruc
   172                              <2> 
   173                              <2> 	struc LBAPACKET
   174 00000000 ????                <2> lpSize:		resw 1
   175 00000002 ????                <2> lpCount:	resw 1
   176 00000004 ????????            <2> lpBuffer:	resd 1
   177 00000008 ????????????????    <2> lpSector:	resq 1
   178                              <2> 	endstruc
   179                              <2> 
   180                              <2> 	struc PARTINFO
   181 00000000 ??                  <2> piBoot:		resb 1
   182 00000001 ??????              <2> piStartCHS:	resb 3
   183 00000004 ??                  <2> piType:		resb 1
   184 00000005 ??????              <2> piEndCHS:	resb 3
   185 00000008 ????????            <2> piStart:	resd 1
   186 0000000C ????????            <2> piLength:	resd 1
   187                              <2> 	endstruc
   188                              <2> 
   189                              <2> ptEmpty:		equ 0
   190                              <2> ptFAT12:		equ 1
   191                              <2> ptFAT16_16BIT_CHS:	equ 4
   192                              <2> ptExtendedCHS:		equ 5
   193                              <2> ptFAT16_CHS:		equ 6
   194                              <2> ptFAT32_CHS:		equ 0Bh
   195                              <2> ptFAT32:		equ 0Ch
   196                              <2> ptFAT16:		equ 0Eh
   197                              <2> ptExtended:		equ 0Fh
   198                              <2> ptLinux:		equ 83h
   199                              <2> ptExtendedLinux:	equ 85h
   200                              <2> 
   201                              <2> 
   202                              <2> 		; Flags of load_unit_flags
   203                              <2> lufForceCHS:		equ 1
   204                              <2> lufForceLBA:		equ 2
   205                              <2> lufForceGeometry:	equ 4
   206                              <2> luf_mask_writable equ lufForceCHS | lufForceLBA | lufForceGeometry
   802                              <1> 
   803                              <1> LOAD_INPUT_FILE_SIZE equ fromparas(paras(-LOADDATA3 + bsBPB + ebpbNew + BPBN_size))
   804                              <1> 
   805                              <1> 	struc LOADSETTINGS
   806 00000000 ????                <1> lsKernelName:	resw 1	; -> kernel file default name
   807 00000002 ????                <1> lsAddName:	resw 1	; -> additional file default name, may be empty string
   808 00000004 ????                <1> lsMinPara:	resw 1	; how much to load at least, fail if file smaller
   809 00000006 ????                <1> lsMaxPara:	resw 1	; how much to load at most (will round up to sector size)
   810 00000008 ????                <1> lsOptions:	resw 1	; option flags
   811 0000000A ????                <1> lsSegment:	resw 1	; => where to load file
   812 0000000C ????????            <1> lsEntry:	resd 1	; relative segment for CS, value for IP
   813 00000010 ????????            <1> lsBPB:		resd 1	; segment for BPB (-1 auto-BPB), offset for BPB
   814 00000014 ????                <1> lsCheckOffset:	resw 1	; offset in file segment of word to check
   815 00000016 ????                <1> lsCheckValue:	resw 1	; value to check for word, 0 if unused
   816 00000018 ????????????????    <1> lsName:		resq 1	; ASCIZ load protocol name
   817                              <1> 	endstruc
   818                              <1> 
   819                              <1> 		numdef LUF_DEFAULT_DISKETTE, 0
   820                              <1> 		numdef LUF_DEFAULT_HARDDISK, 0
   821                              <1> %endif
   822                              <1> 
   823                              <1> 
   824                              <1> %include "mzheader.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug MZ .EXE header macros
     5                              <2> 
     6                              <2> Copyright (C) 1995-2003 Paul Vojta
     7                              <2> Copyright (C) 2008-2023 E. C. Masloch
     8                              <2> 
     9                              <2> Usage of the works is permitted provided that this
    10                              <2> instrument is retained with the works, so that any entity
    11                              <2> that uses the works is notified of this instrument.
    12                              <2> 
    13                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <2> 
    15                              <2> %endif
    16                              <2> 
    17                              <2> 
    18                              <2> 	struc EXEHEADER
    19 00000000 ????                <2> exact_struc_at 00h, exeSignature:	resw 1
    20 00000002 ????                <2> exact_struc_at 02h, exeExtraBytes:	resw 1	; bytes in last page
    21 00000004 ????                <2> exact_struc_at 04h, exePages:		resw 1	; number of 512-byte pages. includes the header!
    22 00000006 ????                <2> exact_struc_at 06h, exeRelocItems:	resw 1	; number of relocation items
    23 00000008 ????                <2> exact_struc_at 08h, exeHeaderSize:	resw 1	; header size in 16-byte paragraphs
    24 0000000A ????                <2> exact_struc_at 0Ah, exeMinAlloc:	resw 1	; minimum (bss) allocation in paragraphs
    25 0000000C ????                <2> exact_struc_at 0Ch, exeMaxAlloc:	resw 1	; maximum (bss) allocation in paragraphs
    26 0000000E ????                <2> exact_struc_at 0Eh, exeInitSS:		resw 1	; init ss (is relocated)
    27 00000010 ????                <2> exact_struc_at 10h, exeInitSP:		resw 1	; init sp
    28 00000012 ????                <2> exact_struc_at 12h, exeChecksum:	resw 1
    29                              <2> exact_struc_at 14h, exeInitCSIP:
    30 00000014 ????                <2> exact_struc_at 14h, exeInitIP:		resw 1	; init ip
    31 00000016 ????                <2> exact_struc_at 16h, exeInitCS:		resw 1	; init cs (is relocated)
    32 00000018 ????                <2> exact_struc_at 18h, exeRelocTable:	resw 1	; byte offset of relocation table
    33                              <2> 		; Each relocation item is a word offset and a word segment.
    34                              <2> 		;  The segment of the item itself is relocated as well.
    35 0000001A ????                <2> exact_struc_at 1Ah, exeOverlayNum:	resw 1
    36                              <2> exact_struc_at 1Ch
    37                              <2> 	endstruc
   825                              <1> 
   826                              <1> 
   827                              <1> 	struc INPUTFILEHANDLE
   828 00000000 ????                <1> ifhHandle:	resw 1
   829 00000002 ????                <1> ifhFlags:	resw 1
   830 00000004 ????????            <1> ifhParentSeek:	resd 1
   831                              <1> 	endstruc
   832                              <1> 
   833                              <1> ifhfIsDup:		equ  100h	; before closing, seek it back
   834                              <1> 	; same value as LBA flag for boot load input files
   835                              <1> ifhfTestReserved1:	equ 1000h
   836                              <1> ifhfTestReserved2:	equ 2000h
   837                              <1> ifhfQuietInput:		equ 4000h	; do not display prompt and input
   838                              <1> ifhfQuietOutput:	equ 8000h	; do not display normal output
   839                              <1> 	; these four are valid for both input file handles and
   840                              <1> 	;  boot load input files.
   841                              <1> 
   842                              <1> 
   843                              <1> 	struc AREASTRUC
   844 00000000 <res 18h>           <1> areastrucEntry:		resb 24
   845 00000018 ????????            <1> areastrucNext:		resd 1
   846 0000001C ????????            <1> areastrucPrev:		resd 1
   847 00000020 ????                <1> areastrucSubAmount:	resw 1
   848 00000022 ????                <1> areastrucSubOffset:	resw 1
   849 00000024 ????                <1> areastrucFunAmount:	resw 1
   850 00000026 ????                <1> areastrucFunOffset:	resw 1
   851                              <1> 	endstruc
   852                              <1> 
   853                              <1> 	struc AREASTRUCSUB
   854 00000000 ????????            <1> areastrucsubLinear:	resd 1
   855 00000004 ????????            <1> areastrucsubLinearEnd:	resd 1
   856 00000008 ????                <1> areastrucsubListOffset:	resw 1
   857 0000000A ????                <1> areastrucsubListAmount:	resw 1
   858                              <1> 	endstruc
   859                              <1> 
   860                              <1> 	struc AREASTRUCFUN
   861 00000000 ????????            <1> areastrucfunLinear:	resd 1
   862 00000004 ????????            <1> areastrucfunLinearEnd:	resd 1
   863 00000008 ????                <1> areastrucfunListOffset:	resw 1
   864 0000000A ????                <1> areastrucfunListAmount:	resw 1
   865                              <1> 	endstruc
   866                              <1> 
   867                              <1> 	struc AREA
   868 00000000 ????                <1> areastart:		resw 1
   869 00000002 ????                <1> areaend:		resw 1
   870 00000004 ????                <1> areamessage:		resw 1
   871 00000006 ????                <1> 			resw 1
   872                              <1> 	endstruc
   873                              <1> 
   874                              <1> 
   875                              <1> %include "isvariab.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug isvariable? function strutures and macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> 	struc ISVARIABLESTRUC
    18 00000000 ????                <2> ivName:		resw 1		; -> name (up to 13 bytes, but actually only 11)
    19                              <2> 				;  (search for ivfNameLengthLimit for limit)
    20                              <2> 				;  (length given by ivFlags & ivfNameLengthMask)
    21                              <2> 	; The ivName pointer is only used for more-byte names. It actually
    22                              <2> 	;  contains the trailer of the name, excluding the prefix formed by
    23                              <2> 	;  the first two bytes. This suffix can be the empty string if the
    24                              <2> 	;  variable in question has a two-byte name.
    25                              <2> 	; (For one-byte names this field is unused and contains zero.)
    26 00000002 ????                <2> ivFlags:	resw 1
    27 00000004 ????                <2> ivAddress:	resw 1		; default -> variable
    28                              <2> 	; The ivAddress field is used by default_variable_setup as the base
    29                              <2> 	;  address for the variable(s). It is also used by var_ext_setup as
    30                              <2> 	;  the ELD code section offset to transfer control to. Otherwise, it
    31                              <2> 	;  is usually set to zero and unused.
    32 00000006 ????                <2> ivSetup:	resw 1		; -> set up code (in expr code section)
    33                              <2> 	; INP:	ax = array index (0-based)
    34                              <2> 	;	di = 0
    35                              <2> 	;	cl = default size of variable (1..4)
    36                              <2> 	;	ch = length of variable name
    37                              <2> 	;	bx -> ISVARIABLESTRUC structure
    38                              <2> 	; CHG:	ax, bx, cx, dx, si, di
    39                              <2> 	; OUT:	NC if valid,
    40                              <2> 	;	 bx -> var, di = 0 or di -> mask
    41                              <2> 	;	 cl = size of variable (1..4)
    42                              <2> 	;	 ch = length of variable name
    43 00000008 ??                  <2> ivArrayLast:	resb 1		; 0 if no array, FFh = 256 entries
    44                              <2> 	; The ivArrayLast field is used by the dispatcher to determine
    45                              <2> 	;  whether to support array index expressions. It is checked
    46                              <2> 	;  before decrementing the index if ivfArrayOneBased is set.
    47 00000009 ??                  <2> ivArrayBetween: resb 1		; how many bytes to skip for each index
    48                              <2> 	; The ivArrayBetween field is only used by default_variable_setup.
    49                              <2> 	endstruc
    50                              <2> 
    51                              <2> ivfNameLengthMask:	equ 15	; gives name trailer length, 0 to 11
    52                              <2> ivfNameLengthLimit:	equ 13
    53                              <2> ivfVarLengthShift:	equ 4
    54                              <2> ivfVarLengthMask:	equ 3 << ivfVarLengthShift
    55                              <2> 				; gives default variable size minus 1
    56                              <2> ivfReadOnly:		equ 80h	; variable cannot be written at all
    57                              <2> ivfArrayOneBased:	equ 100h; first array entry is 1 not 0 (ivArrayLast > 0)
    58                              <2> ivfArrayOptional:	equ 200h; array index expression is optional
    59                              <2> ivfSeparatorSpecial:	equ 400h; used for RIxxP/L/S/O
    60                              <2> 
    61                              <2> %define ISVARIABLESTRINGS db "",db ""
    62                              <2> %define IVS_ONEBYTE_NAMES ""
    63                              <2> %define IVS_MOREBYTE_NAMEHEADERS ""
    64                              <2> %assign IVS_HAVE_ONEBYTE 0
    65                              <2> %assign IVS_SINGLE_ONEBYTE 1
    66                              <2> 
    67                              <2> 		; %1 = name string
    68                              <2> 		; %2 = default variable length, 1 to 4
    69                              <2> 		; %3 = flags to set (except name length and var length)
    70                              <2> 		; %4 = ivAddress value
    71                              <2> 		; %5 = ivArrayLast, defaults to 0 (no array)
    72                              <2> 		; %6 = ivArrayBetween, defaults to 0 (immediately consecutive)
    73                              <2> 		; %7 = ivSetup, defaults to default_variable_setup
    74                              <2> 	%macro isvariablestruc 4-7.nolist 0, 0, default_variable_setup
    75                              <2> %push
    76                              <2> %strlen %$namelength %1
    77                              <2> %if %$namelength > ivfNameLengthLimit
    78                              <2>  %error Expected at most 13-byte name (or adjust isvariable? code)
    79                              <2> %endif
    80                              <2> %if IVS_ONEBYTE && %$namelength != 1
    81                              <2>  %error Expected a one-byte name
    82                              <2> %elif ! IVS_ONEBYTE && %$namelength < 2
    83                              <2>  %error Expected at least a two-byte name
    84                              <2> %endif
    85                              <2> %if IVS_ONEBYTE
    86                              <2>  %define IVS_SINGLE_ONEBYTE_NAME %1
    87                              <2>  %if IVS_HAVE_ONEBYTE
    88                              <2>   %assign IVS_SINGLE_ONEBYTE 0
    89                              <2>  %endif
    90                              <2>  %assign IVS_HAVE_ONEBYTE 1
    91                              <2>  %assign %$namelength 0
    92                              <2>  %xdefine IVS_ONEBYTE_NAMES IVS_ONEBYTE_NAMES, %1
    93                              <2>  %%name equ 0
    94                              <2> %else
    95                              <2>  %assign %$namelength %$namelength - 2
    96                              <2>  %substr %$nametrailer %1 3,-1
    97                              <2>  %substr %$nameheader %1 1,2
    98                              <2>  %xdefine IVS_MOREBYTE_NAMEHEADERS IVS_MOREBYTE_NAMEHEADERS, %$nameheader
    99                              <2>  %xdefine ISVARIABLESTRINGS ISVARIABLESTRINGS, %%name:, {db %$nametrailer}
   100                              <2> %endif
   101                              <2> 
   102                              <2> %assign %$varlength %2 - 1	; 0 means one byte, 1 means two bytes,
   103                              <2> 				;  2 means three bytes, 3 means four bytes
   104                              <2> 	istruc ISVARIABLESTRUC
   105                              <2> at ivName,		dw %%name
   106                              <2>  IV_NAME_RELOCATION
   107                              <2> at ivFlags,		dw %$$namelength | (%$$varlength << ivfVarLengthShift) | %3
   108                              <2> at ivAddress,		dw %4
   109                              <2>  IV_ADDRESS_RELOCATION
   110                              <2> at ivSetup,		dw %7
   111                              <2>  IV_SETUP_RELOCATION
   112                              <2> at ivArrayLast,		db %5
   113                              <2> at ivArrayBetween,	db %6
   114                              <2> 	iend
   115                              <2> %pop
   116                              <2> %ifndef SECTION_OF_%7
   117                              <2>  %error Unknown target section for symbol %7
   118                              <2> %elifnidni %[SECTION_OF_%7], _EXPR_SECTION
   119                              <2>  %error Wrong section for symbol %7: section_of=SECTION_OF_%7, expr=_EXPR_SECTION
   120                              <2> %endif
   121                              <2> 	%endmacro
   122                              <2> 
   123                              <2> %define IV_NAME_RELOCATION
   124                              <2> %define IV_ADDRESS_RELOCATION
   125                              <2> %define IV_SETUP_RELOCATION
   126                              <2> 
   127                              <2> 	%macro isvariablestrings 2-*.nolist
   128                              <2> %rep %0
   129                              <2>  %1
   130                              <2>  %rotate 1
   131                              <2> %endrep
   132                              <2> 	%endmacro
   876                              <1> 
   877                              <1> 
   878                              <1> %include "386.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug 386 patch macros
     5                              <2> 
     6                              <2> Copyright (C) 2008-2026 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 	numdef LINK, 0
    17                              <2> 
    18                              <2> 	numdef WPT_LABELS, 0
    19                              <2> 		; This used to be required, because CODESECTIONFIXUP used
    20                              <2> 		;  ldebug_data_entry_size, which is not yet defined during
    21                              <2> 		;  assembling of (most) lDEBUG_CODE fragments.
    22                              <2> 		; However, assembling DebugX with this option selected
    23                              <2> 		;  took more than 2 minutes, so the non-label variant
    24                              <2> 		;  is clearly to be preferred when available.
    25                              <2> 		; Now that lDEBUG_CODE has vstart=0 we can use the
    26                              <2> 		;  CODESECTIONFIXUP again and thus disable this option.
    27                              <2> 
    28                              <2> %ifn _LINK
    29                              <2> %define PATCH_NO386_TABLE ""
    30                              <2> %define PATCH_386_TABLE ""
    31                              <2> %define PATCH_NO386_TABLE2 ""
    32                              <2> %define PATCH_386_TABLE2 ""
    33                              <2> %define PATCH_NO386_TABLEENTRY ""
    34                              <2> %define PATCH_386_TABLEENTRY ""
    35                              <2> %endif
    36                              <2> 
    37                              <2> %if _ONLY386
    38                              <2> 		; Default patch macros if only running on 386+.
    39                              <2> %define _386_o32 o32
    40                              <2> %define _386_a32 a32
    41                              <2> %define _386_jmps jmp short
    42                              <2> %define _386_jmpn jmp near
    43                              <2> %define _no386_jmps comment
    44                              <2> %define _no386_jmpn comment
    45                              <2> 	%macro _386 0-1+.nolist
    46                              <2> [cpu 386]			; change CPU type
    47                              <2> 		%1		; write instruction
    48                              <2> __CPU__				; reset CPU type
    49                              <2> 	%endmacro
    50                              <2> %define _no386 comment
    51                              <2> %elif _ONLYNON386
    52                              <2> 		; Default patch macros if only running on non-386.
    53                              <2> %define _386_o32
    54                              <2> %define _386_a32
    55                              <2> %define _386_jmps comment
    56                              <2> %define _386_jmpn comment
    57                              <2> %define _no386_jmps jmp short
    58                              <2> %define _no386_jmpn jmp near
    59                              <2> %define _386 comment
    60                              <2> %define _no386
    61                              <2> %else
    62                              <2> 
    63                              <2> ; These macros are to make DEBUG's 386 support as small as
    64                              <2> ; possible. To achieve this, two patch tables are created
    65                              <2> ; in the initialisation code. One of the tables is used if
    66                              <2> ; the CPU is a 386+, the other one if it isn't. The bytes
    67                              <2> ; pointed to in the used table are over-written with NOP
    68                              <2> ; instructions. (The patched bytes are usually address or
    69                              <2> ; operand size prefixes or jumps that branch to 386/non-386
    70                              <2> ; code.)
    71                              <2> 
    72                              <2> ; There are a few special patches that require the
    73                              <2> ; initialisation code to write specific bytes other than
    74                              <2> ; NOP instructions for lower resident memory usage.
    75                              <2> ; Two are in the run: code, three in pmentry.asm.
    76                              <2> 
    77                              <2> %if _LINK
    78                              <2> 
    79                              <2> %imacro wllist 1-3.nolist
    80                              <2> %ifnempty %3
    81                              <2>  %deftok %%filenametoken %3
    82                              <2> %else
    83                              <2>  %deftok %%filenametoken __FILE__
    84                              <2> %endif
    85                              <2>  global ..@wllist_%1?%[%%l]%[%%filenametoken]
    86                              <2> ..@wllist_%1?%[%%l]%[%%filenametoken]: %2
    87                              <2> %endmacro
    88                              <2> 
    89                              <2> 	%macro patch386 2-3.nolist 1
    90                              <2> %define %%repeat
    91                              <2> %if %3 != 1
    92                              <2>  %define %%repeat r%3_
    93                              <2> %endif
    94                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
    95                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table, %2
    96                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
    97                              <2>  wllist %[%%repeat]Lpatch_%{1}386_table2, %2
    98                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
    99                              <2>  wllist %[%%repeat]Lpatch_%{1}386_tableentry, %2
   100                              <2> %else
   101                              <2>  %error Wrong section
   102                              <2> %endif
   103                              <2> 	%endmacro
   104                              <2> 
   105                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   106                              <2> 	%macro _386_o32 0-1+.nolist
   107                              <2> _386		o32
   108                              <2> 		%1
   109                              <2> 	%endmacro
   110                              <2> 
   111                              <2> 		; Address size 32-bit prefix if 386+ CPU
   112                              <2> 	%macro _386_a32 0-1+.nolist
   113                              <2> _386		a32
   114                              <2> 		%1
   115                              <2> 	%endmacro
   116                              <2> 
   117                              <2> 		; Short jump if 386+ CPU
   118                              <2> 	%macro _386_jmps 1.nolist
   119                              <2> _386		jmp short %1
   120                              <2> 	%endmacro
   121                              <2> 
   122                              <2> 		; Near jump if 386+ CPU
   123                              <2> 	%macro _386_jmpn 1.nolist
   124                              <2> _386		jmp near %1
   125                              <2> 	%endmacro
   126                              <2> 
   127                              <2> 		; Short jump if no 386+ CPU
   128                              <2> 	%macro _no386_jmps 1.nolist
   129                              <2> _no386		jmp short %1
   130                              <2> 	%endmacro
   131                              <2> 
   132                              <2> 		; Near jump if no 386+ CPU
   133                              <2> 	%macro _no386_jmpn 1.nolist
   134                              <2> _no386		jmp near %1
   135                              <2> 	%endmacro
   136                              <2> 
   137                              <2> 		; Instruction if 386+ CPU
   138                              <2> 	%macro _386 0-1+.nolist
   139                              <2> [cpu 386]			; change CPU type
   140                              <2> %%entry:
   141                              <2> 		%1		; write instruction
   142                              <2> __CPU__				; reset CPU type
   143                              <2> %assign %%length ($ - %%entry)
   144                              <2>  patch386 no, equ %%entry, %%length
   145                              <2> 	%endmacro
   146                              <2> 
   147                              <2> 		; Instruction if no 386+ CPU
   148                              <2> 	%macro _no386 0-1+.nolist
   149                              <2> %%entry:
   150                              <2> 		%1		; write instruction
   151                              <2> %assign %%length ($ - %%entry)
   152                              <2>  patch386 , equ %%entry, %%length
   153                              <2> 	%endmacro
   154                              <2> 
   155                              <2> %else
   156                              <2> 	%macro patch386 2+.nolist
   157                              <2> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   158                              <2>  %define PATCH_%{1}386_TABLE %[PATCH_%{1}386_TABLE], %2
   159                              <2> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   160                              <2>  %define PATCH_%{1}386_TABLE2 %[PATCH_%{1}386_TABLE2], %2
   161                              <2> %elifidn _CURRENT_SECTION, lDEBUG_DATA_ENTRY
   162                              <2>  %define PATCH_%{1}386_TABLEENTRY %[PATCH_%{1}386_TABLEENTRY], %2
   163                              <2> %else
   164                              <2>  %error Wrong section
   165                              <2> %endif
   166                              <2> 	%endmacro
   167                              <2> 
   168                              <2> %if _WPT_LABELS
   169                              <2> 	; These forms provide verbose info by defining a
   170                              <2> 	; meaningful label for each patch. That fills up
   171                              <2> 	; the map file and might take longer though.
   172                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   173                              <2> 	%macro _386_o32 0-1+.nolist
   174                              <2> %%386_o32:	o32
   175                              <2> patch386 NO, %%386_o32
   176                              <2> 		%1
   177                              <2> 	%endmacro
   178                              <2> 
   179                              <2> 		; Address size 32-bit prefix if 386+ CPU
   180                              <2> 	%macro _386_a32 0-1+.nolist
   181                              <2> %%386_a32:	a32
   182                              <2> patch386 NO, %%386_a32
   183                              <2> 		%1
   184                              <2> 	%endmacro
   185                              <2> 
   186                              <2> 		; Short jump if 386+ CPU
   187                              <2> 	%macro _386_jmps 1.nolist
   188                              <2> %%386_jmps:	jmp short %1
   189                              <2> patch386 NO, %%386_jmps,%%386_jmps+1
   190                              <2> 	%endmacro
   191                              <2> 
   192                              <2> 		; Near jump if 386+ CPU
   193                              <2> 	%macro _386_jmpn 1.nolist
   194                              <2> %%386_jmpn:	jmp near %1
   195                              <2> patch386 NO, %%386_jmpn,%%386_jmpn+1,%%386_jmpn+2
   196                              <2> 	%endmacro
   197                              <2> 
   198                              <2> 		; Short jump if no 386+ CPU
   199                              <2> 	%macro _no386_jmps 1.nolist
   200                              <2> %%no386_jmps:	jmp short %1
   201                              <2> patch386 , %%no386_jmps,%%no386_jmps+1
   202                              <2> 	%endmacro
   203                              <2> 
   204                              <2> 		; Near jump if no 386+ CPU
   205                              <2> 	%macro _no386_jmpn 1.nolist
   206                              <2> %%no386_jmpn:	jmp near %1
   207                              <2> patch386 , %%no386_jmpn,%%no386_jmpn+1,%%no386_jmpn+2
   208                              <2> 	%endmacro
   209                              <2> 
   210                              <2> 		; Instruction if 386+ CPU
   211                              <2> 	%macro _386 0-1+.nolist
   212                              <2> [cpu 386]			; change CPU type
   213                              <2> %%386_instr:	%1		; write instruction
   214                              <2> __CPU__				; reset CPU type
   215                              <2> 
   216                              <2> %assign %%INSTRCOUNT 0
   217                              <2> %rep $-%%386_instr		; count size of instruction
   218                              <2>  patch386 NO, %%386_instr+%[%%INSTRCOUNT]
   219                              <2> 				; write a patch for each byte
   220                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   221                              <2> %endrep
   222                              <2> %undef %%INSTRCOUNT
   223                              <2> 	%endmacro
   224                              <2> 
   225                              <2> 		; Instruction if no 386+ CPU
   226                              <2> 	%macro _no386 0-1+.nolist
   227                              <2> %%no386_instr:	%1		; write instruction
   228                              <2> 
   229                              <2> %assign %%INSTRCOUNT 0
   230                              <2> %rep $-%%no386_instr		; count size of instruction
   231                              <2>  patch386 , %%no386_instr+%[%%INSTRCOUNT]
   232                              <2> 				; write a patch for each byte
   233                              <2>  %assign %%INSTRCOUNT %%INSTRCOUNT+1
   234                              <2> %endrep
   235                              <2> %undef %%INSTRCOUNT
   236                              <2> 	%endmacro
   237                              <2> %else	; _WPT_LABELS
   238                              <2> 		; Operand size 32-bit prefix if 386+ CPU
   239                              <2> 	%macro _386_o32 0-1+.nolist
   240                              <2> _386		o32
   241                              <2> 		%1
   242                              <2> 	%endmacro
   243                              <2> 
   244                              <2> 		; Address size 32-bit prefix if 386+ CPU
   245                              <2> 	%macro _386_a32 0-1+.nolist
   246                              <2> _386		a32
   247                              <2> 		%1
   248                              <2> 	%endmacro
   249                              <2> 
   250                              <2> 		; Short jump if 386+ CPU
   251                              <2> 	%macro _386_jmps 1.nolist
   252                              <2> _386		jmp short %1
   253                              <2> 	%endmacro
   254                              <2> 
   255                              <2> 		; Near jump if 386+ CPU
   256                              <2> 	%macro _386_jmpn 1.nolist
   257                              <2> _386		jmp near %1
   258                              <2> 	%endmacro
   259                              <2> 
   260                              <2> 		; Short jump if no 386+ CPU
   261                              <2> 	%macro _no386_jmps 1.nolist
   262                              <2> _no386		jmp short %1
   263                              <2> 	%endmacro
   264                              <2> 
   265                              <2> 		; Near jump if no 386+ CPU
   266                              <2> 	%macro _no386_jmpn 1.nolist
   267                              <2> _no386		jmp near %1
   268                              <2> 	%endmacro
   269                              <2> 
   270                              <2> 		; Instruction if 386+ CPU
   271                              <2> 	%macro _386 0-1+.nolist
   272                              <2> %push
   273                              <2> [cpu 386]			; change CPU type
   274                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   275                              <2> 		%1		; write instruction
   276                              <2> __CPU__				; reset CPU type
   277                              <2> 
   278                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   279                              <2> 				; count size of instruction
   280                              <2>  patch386 NO, %[%$entry]	; write a patch for each byte
   281                              <2>  %assign %$entry %$entry+1
   282                              <2> %endrep
   283                              <2> %pop
   284                              <2> 	%endmacro
   285                              <2> 
   286                              <2> 		; Instruction if no 386+ CPU
   287                              <2> 	%macro _no386 0-1+.nolist
   288                              <2> %push
   289                              <2> %assign %$entry $ + _CURRENT_SECTION %+ FIXUP
   290                              <2> 		%1		; write instruction
   291                              <2> 
   292                              <2> %rep ($ + _CURRENT_SECTION %+ FIXUP) - %$entry
   293                              <2> 				; count size of instruction
   294                              <2>  patch386 , %[%$entry]		; write a patch for each byte
   295                              <2>  %assign %$entry %$entry+1
   296                              <2> %endrep
   297                              <2> %pop
   298                              <2> 	%endmacro
   299                              <2> %endif	; _WPT_LABELS
   300                              <2> %endif	; _LINK
   301                              <2> 
   302                              <2> %endif
   303                              <2> 
   304                              <2> 		; Patch macros but for cases where the 386+
   305                              <2> 		; instructions should only be generated for
   306                              <2> 		; DEBUGX (i.e. for 32-bit DPMI addressing code).
   307                              <2> %if _PM
   308                              <2> %define _386_PM_o32	_386_o32
   309                              <2> %define _386_PM_a32	_386_a32
   310                              <2> %define _386_PM_jmps	_386_jmps
   311                              <2> %define _386_PM_jmpn	_386_jmpn
   312                              <2> %define _386_PM		_386
   313                              <2> %else
   314                              <2> %define _386_PM_o32
   315                              <2> %define _386_PM_a32
   316                              <2> %define _386_PM_jmps	comment
   317                              <2> %define _386_PM_jmpn	comment
   318                              <2> %define _386_PM		comment
   319                              <2> %endif
   320                              <2> 
   321                              <2> 
   322                              <2> %ifn _LINK
   323                              <2> %macro __writepatchtable2 0-*.nolist
   324                              <2> %if %0 & 1
   325                              <2>  %fatal Expected even number of arguments
   326                              <2> %endif
   327                              <2> %rep %0 >> 1
   328                              <2> 	%1 %2
   329                              <2> %rotate 2
   330                              <2> %endrep
   331                              <2> %endmacro
   332                              <2> 
   333                              <2> %macro __patchtable2_entry 0.nolist
   334                              <2>   ; only if this isn't the first (pseudo-)entry
   335                              <2>   %if %$lastcount != 0
   336                              <2>     %assign %$runscount %[%$runscount]+1
   337                              <2>    ; if the offset from %$previous is less than 255
   338                              <2>    %if (%$last-%$previous) < 255
   339                              <2>     %assign %$$method2tablesize %$$method2tablesize+1
   340                              <2>     ; then write a single byte (number of bytes not to patch between)
   341                              <2>     %xdefine %$$method2list %$$method2list,db,%$last-%$previous
   342                              <2>    %else
   343                              <2>     ; otherwise write a 255 ("reposition") and write the 16-bit address afterwards
   344                              <2>     %assign %$$method2tablesize %$$method2tablesize+3
   345                              <2>     %xdefine %$$method2list %$$method2list,db,255,dw,%$last
   346                              <2>     %assign %$reposcount %[%$reposcount]+1
   347                              <2>    %endif
   348                              <2>    %if %$lastcount == 1
   349                              <2>     %assign %$onecount %[%$onecount]+1
   350                              <2>    %endif
   351                              <2>    %assign %$$method2tablesize %$$method2tablesize+1
   352                              <2>    ; and write the number of bytes to be patched
   353                              <2>    %xdefine %$$method2list %$$method2list,db,%$lastcount
   354                              <2>    ; define %$previous for the next entry: it points to the next non-patched byte
   355                              <2>    %define %$previous (%[%$last]+%[%$lastcount])
   356                              <2>   %endif
   357                              <2> %endmacro
   358                              <2> 
   359                              <2> %macro writepatchtable 2-*.nolist
   360                              <2> 
   361                              <2> 	numdef %{1}_FORCE_METHOD, 0
   362                              <2> %push
   363                              <2> 		; Determine length of simple table:
   364                              <2> %assign %$method1tablesize (%0 - 2)*2
   365                              <2> 
   366                              <2> %if !_%{1}_FORCE_METHOD || _%{1}_FORCE_METHOD == 2
   367                              <2> 		; Determine length of complicated table:
   368                              <2> %assign %$method2tablesize 0
   369                              <2> %define %$method2list db,""
   370                              <2> %push
   371                              <2> %if _WPT_LABELS
   372                              <2>  %define %$previous code_start	; if list contains labels
   373                              <2> %else
   374                              <2>  %define %$previous 0
   375                              <2> %endif
   376                              <2> %define %$last %[%$previous]
   377                              <2> %assign %$lastcount 0
   378                              <2> %assign %$onecount 0
   379                              <2> %assign %$reposcount 0
   380                              <2> %assign %$bytescount %0 - 2
   381                              <2> %assign %$runscount 0
   382                              <2> %rotate 1
   383                              <2> %rep %0 - 2
   384                              <2>  %rotate 1
   385                              <2>  ;if  it continues the previous patch   and not too long   and this isn't the first
   386                              <2>  %if ((%$last+%$lastcount) == %1) && (%$lastcount < 255) && (%$lastcount != 0)
   387                              <2>   ; then do not write an entry, just increase the patch's size
   388                              <2>   %assign %$lastcount %[%$lastcount]+1
   389                              <2>  %else
   390                              <2>   ; otherwise write the last entry
   391                              <2>   __patchtable2_entry
   392                              <2>   ; define new %$last to this parameter, %$lastcount to one
   393                              <2>   %define %$last %1
   394                              <2>   %assign %$lastcount 1
   395                              <2>  %endif
   396                              <2> %endrep
   397                              <2> __patchtable2_entry
   398                              <2> 
   399                              <2> ; at the end, there's a patch with offset 0, size 0
   400                              <2> %assign %$$method2tablesize %$$method2tablesize+2
   401                              <2> %xdefine %$$method2list %$$method2list,db,0,db,0
   402                              <2> 
   403                              <2> %assign %$$onecount %$onecount
   404                              <2> %assign %$$reposcount %$reposcount
   405                              <2> %assign %$$bytescount %$bytescount
   406                              <2> %assign %$$runscount %$runscount
   407                              <2> %pop
   408                              <2> %rotate 1
   409                              <2> %endif
   410                              <2> 
   411                              <2> %if _%{1}_FORCE_METHOD == 2
   412                              <2>  %define __%{1}_method 2
   413                              <2> %elif _%{1}_FORCE_METHOD == 1
   414                              <2>  %define __%{1}_method 1
   415                              <2> %else
   416                              <2>  %if _%{1}_FORCE_METHOD
   417                              <2>   %fatal Invalid forced method selected: _%{1}_FORCE_METHOD
   418                              <2>  %endif
   419                              <2>  %if %$method1tablesize > (%$method2tablesize+20)
   420                              <2>   %define __%{1}_method 2
   421                              <2>  %else
   422                              <2>   %define __%{1}_method 1
   423                              <2>  %endif
   424                              <2> %endif
   425                              <2> 
   426                              <2> 
   427                              <2> %1:
   428                              <2> %if __%{1}_method == 2
   429                              <2> 	__writepatchtable2 %$method2list
   430                              <2> 	endarea %1
   431                              <2> %assign %$size %1_size
   432                              <2> %warning %1: %$size bytes (Method 2)
   433                              <2> %warning 1B=%$onecount repo=%$reposcount run=%$runscount byte=%$bytescount
   434                              <2> %else
   435                              <2> %rotate 1
   436                              <2> %rep %0 - 2
   437                              <2> %rotate 1
   438                              <2> 	dw %1
   439                              <2> %endrep
   440                              <2> %rotate 1
   441                              <2> 	endarea %1
   442                              <2> %assign %$size %1_size
   443                              <2> %warning %1: %$size bytes (Method 1)
   444                              <2> %1.amount equ %1_size_w
   445                              <2> %endif
   446                              <2> %pop
   447                              <2> %endmacro
   448                              <2> %endif
   879                              <1> 
   880                              <1> 
   881                              <1> %if _VDD
   882                              <1> ; standard BOPs for communication with DEBXXVDD on NT platforms
   883                              <1> %macro RegisterModule 0.nolist
   884                              <1> 	db 0C4h, 0C4h, 58h, 0
   885                              <1> 	nop
   886                              <1> %endmacro
   887                              <1> %macro UnRegisterModule 0.nolist
   888                              <1> 	db 0C4h, 0C4h, 58h, 1
   889                              <1> 	nop
   890                              <1> %endmacro
   891                              <1> %macro DispatchCall 0.nolist
   892                              <1> 	db 0C4h, 0C4h, 58h, 2
   893                              <1> 	nop
   894                              <1> %endmacro
   895                              <1> %endif
   896                              <1> 
   897                              <1> %assign CODE_INSURE_COUNT 0
   898                              <1> 
   899                              <1> 		; The entry_to_code_seg/_sel dispatcher in lDEBUG_DATA_ENTRY
   900                              <1> 		;  detects mistaken debugger breakpoints in its
   901                              <1> 		;  in-code-parameter by checking for a low-byte
   902                              <1> 		;  value equal to 0CCh (one-byte int3 opcode).
   903                              <1> 		; Therefore, we insure that all destinations jumped to
   904                              <1> 		;  via that dispatcher do not happen to be located
   905                              <1> 		;  on an offset that gives 0CCh in the low byte.
   906                              <1> 	%imacro code_insure_low_byte_not_0CCh 0.nolist
   907                              <1> %ifn _LINK
   908                              <1>  %if (($ - _CURRENT_SECTION %+ _start) & 0FFh) == 0CCh
   909                              <1> 	nop
   910                              <1>   %assign CODE_INSURE_COUNT 1 + CODE_INSURE_COUNT
   911                              <1>  %endif
   912                              <1> %endif
   913                              <1> 	%endmacro
   914                              <1> 
   915                              <1> 
   916                              <1> 		; dual code segments
   917                              <1> %if _DUALCODE && _PM
   918                              <1> 
   919                              <1> %if _DEBUG
   920                              <1> %idefine dualfunction comment
   921                              <1> %else
   922                              <1> %idefine dualfunction code_insure_low_byte_not_0CCh
   923                              <1> %endif
   924                              <1> 
   925                              <1> %idefine dualreturn call _CURRENT_SECTION %+ _dualret_helper
   926                              <1> %idefine dualdistance far
   927                              <1> 	%imacro dualcall 1.nolist
   928                              <1> %ifndef SECTION_OF_%1
   929                              <1>  %error Unknown target section for symbol %1
   930                              <1> %endif
   931                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _dualcall_helper
   932                              <1>  %if _DEBUG
   933                              <1> 	jmp strict short %%skipdata
   934                              <1>  %endif
   935                              <1> 	dw %1
   936                              <1> %%skipdata:
   937                              <1> 	%endmacro
   938                              <1> 	%imacro nearcall 1.nolist
   939                              <1> %ifndef SECTION_OF_%1
   940                              <1>  %error Unknown target section for symbol %1
   941                              <1> %endif
   942                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   943                              <1> 	call %1
   944                              <1> %else
   945                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
   946                              <1>  %if _DEBUG
   947                              <1> 	jmp strict short %%skipdata
   948                              <1>  %endif
   949                              <1> 	dw %1
   950                              <1> %%skipdata:
   951                              <1> %endif
   952                              <1> 	%endmacro
   953                              <1> 
   954                              <1> %elif _DUALCODE && ! _PM
   955                              <1> 
   956                              <1> %idefine dualfunction comment
   957                              <1> %idefine dualreturn
   958                              <1> %idefine dualdistance far
   959                              <1> 
   960                              <1> %ifn _LINK
   961                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE ""
   962                              <1> %define PATCH_RELOCATE_FROM_lDEBUG_CODE2 ""
   963                              <1> 	%imacro dualcall 1.nolist
   964                              <1> %ifndef SECTION_OF_%1
   965                              <1>  %error Unknown target section for symbol %1
   966                              <1> %endif
   967                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
   968                              <1> 	push cs
   969                              <1> 	call %1
   970                              <1> %else
   971                              <1> 	call relocatedzero:%1
   972                              <1> %push
   973                              <1> %assign %$entry ($ + _CURRENT_SECTION %+ FIXUP) - 2
   974                              <1> 	relocatelist _CURRENT_SECTION, %$entry
   975                              <1> %pop
   976                              <1> %endif
   977                              <1> 	%endmacro
   978                              <1> 	%imacro relocatelist 2.nolist
   979                              <1>  %define PATCH_RELOCATE_FROM_%1 %[PATCH_RELOCATE_FROM_%1],%2
   980                              <1> 	%endmacro
   981                              <1> %else		; _LINK
   982                              <1> 	%idefine dualcall dualcall_with_filename __FILE__,
   983                              <1> 	%imacro dualcall_with_filename 2.nolist
   984                              <1> %ifndef SECTION_OF_%2
   985                              <1>  %error Unknown target section for symbol %2
   986                              <1> %endif
   987                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
   988                              <1> 	push cs
   989                              <1> 	call %2
   990                              <1> %else
   991                              <1> 	call relocatedzero:%2
   992                              <1> %ifidn _CURRENT_SECTION, lDEBUG_CODE
   993                              <1>  wllist Lrelocate_from_code, equ $ - 2, %1
   994                              <1> %elifidn _CURRENT_SECTION, lDEBUG_CODE2
   995                              <1>  wllist Lrelocate_from_code2, equ $ - 2, %1
   996                              <1> %else
   997                              <1>  %error Wrong section
   998                              <1> %endif
   999                              <1> %endif
  1000                              <1> 	%endmacro
  1001                              <1> %endif		; _LINK
  1002                              <1>  %if _DUALCODENEARDUAL
  1003                              <1> 
  1004                              <1> %if _LINK
  1005                              <1> 	%idefine nearcall nearcall_with_filename __FILE__,
  1006                              <1> 	%imacro nearcall_with_filename 2
  1007                              <1> %ifndef SECTION_OF_%2
  1008                              <1>  %error Unknown target section for symbol %2
  1009                              <1> %endif
  1010                              <1> %ifidni %[SECTION_OF_%2], _CURRENT_SECTION
  1011                              <1> 	call %2
  1012                              <1> %else
  1013                              <1>  %push
  1014                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1015                              <1>  %xdefine %$targetsection SECTION_OF_%2
  1016                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1017                              <1>   %ifndef NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1018                              <1> 	hiddenusesection %$targetsection
  1019                              <1> %define NEARCALL_THUNK_TO_%2%[%%filenametoken] %%nearcall_thunk_to_%2%[%%filenametoken]
  1020                              <1> section_of %%nearcall_thunk_to_%2%[%%filenametoken]
  1021                              <1> dualfunction
  1022                              <1> %%nearcall_thunk_to_%2%[%%filenametoken]:
  1023                              <1> 	call %2
  1024                              <1> 	dualreturn
  1025                              <1> 	retf
  1026                              <1> 
  1027                              <1> 	hiddenusesection %$originalsection
  1028                              <1>   %endif
  1029                              <1>  %pop
  1030                              <1> 	dualcall_with_filename %1, NEARCALL_THUNK_TO_%2%[%%filenametoken]
  1031                              <1> %endif
  1032                              <1> 	%endmacro
  1033                              <1> %elif _LINK_COMPAT	; _LINK
  1034                              <1> 	%imacro nearcall 1
  1035                              <1> %ifndef SECTION_OF_%1
  1036                              <1>  %error Unknown target section for symbol %1
  1037                              <1> %endif
  1038                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1039                              <1> 	call %1
  1040                              <1> %else
  1041                              <1>  %push
  1042                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1043                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1044                              <1>  %deftok %%filenametoken SOURCEFILENAME
  1045                              <1>   %ifndef NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1046                              <1> 	hiddenusesection %$targetsection
  1047                              <1> %define NEARCALL_THUNK_TO_%1%[%%filenametoken] %%nearcall_thunk_to_%1%[%%filenametoken]
  1048                              <1> section_of %%nearcall_thunk_to_%1%[%%filenametoken]
  1049                              <1> dualfunction
  1050                              <1> %%nearcall_thunk_to_%1%[%%filenametoken]:
  1051                              <1> 	call %1
  1052                              <1> 	dualreturn
  1053                              <1> 	retf
  1054                              <1> 
  1055                              <1> 	hiddenusesection %$originalsection
  1056                              <1>   %endif
  1057                              <1>  %pop
  1058                              <1> 	dualcall NEARCALL_THUNK_TO_%1%[%%filenametoken]
  1059                              <1> %endif
  1060                              <1> 	%endmacro
  1061                              <1> %else		; _LINK, _LINK_COMPAT
  1062                              <1> 	%imacro nearcall 1
  1063                              <1> %ifndef SECTION_OF_%1
  1064                              <1>  %error Unknown target section for symbol %1
  1065                              <1> %endif
  1066                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1067                              <1> 	call %1
  1068                              <1> %else
  1069                              <1>  %push
  1070                              <1>  %xdefine %$originalsection _CURRENT_SECTION
  1071                              <1>  %xdefine %$targetsection SECTION_OF_%1
  1072                              <1>   %ifndef NEARCALL_THUNK_TO_%1
  1073                              <1> 	hiddenusesection %$targetsection
  1074                              <1> %define NEARCALL_THUNK_TO_%1 %%nearcall_thunk_to_%1
  1075                              <1> section_of %%nearcall_thunk_to_%1
  1076                              <1> dualfunction
  1077                              <1> %%nearcall_thunk_to_%1:
  1078                              <1> 	call %1
  1079                              <1> 	dualreturn
  1080                              <1> 	retf
  1081                              <1> 
  1082                              <1> 	hiddenusesection %$originalsection
  1083                              <1>   %endif
  1084                              <1>  %pop
  1085                              <1> 	dualcall NEARCALL_THUNK_TO_%1
  1086                              <1> %endif
  1087                              <1> 	%endmacro
  1088                              <1> %endif		; _LINK, _LINK_COMPAT
  1089                              <1>  %else
  1090                              <1> 	%imacro nearcall 1.nolist
  1091                              <1> %ifndef SECTION_OF_%1
  1092                              <1>  %error Unknown target section for symbol %1
  1093                              <1> %endif
  1094                              <1> %ifidni %[SECTION_OF_%1], _CURRENT_SECTION
  1095                              <1> 	call %1
  1096                              <1> %else
  1097                              <1> 	call _CURRENT_SECTION %+ _to_ %+ %[SECTION_OF_%1] %+ _nearcall_helper
  1098                              <1>  %if _DEBUG
  1099                              <1> 	jmp strict short %%skipdata
  1100                              <1>  %endif
  1101                              <1> 	dw %1
  1102                              <1> %%skipdata:
  1103                              <1> %endif
  1104                              <1> 	%endmacro
  1105                              <1>  %endif
  1106                              <1> %elif ! _DUALCODE
  1107                              <1> 
  1108                              <1> %idefine dualfunction comment
  1109                              <1> %idefine dualreturn
  1110                              <1> %idefine dualdistance near
  1111                              <1> 	%imacro dualcall 1.nolist
  1112                              <1> 	call %1
  1113                              <1> 	%endmacro
  1114                              <1> 	%imacro nearcall 1.nolist
  1115                              <1> 	call %1
  1116                              <1> 	%endmacro
  1117                              <1> %assign _SYMBOLICDUALCODE 0
  1118                              <1> %assign _SYMBOLASMDUALCODE 0
  1119                              <1> 
  1120                              <1> %else
  1121                              <1>  %error Unexpected defines
  1122                              <1> %endif
  1123                              <1> 
  1124                              <1> %ifn _SYMBOLICDUALCODE
  1125                              <1>  %assign _SYMBOLASMDUALCODE 0
  1126                              <1> %endif
  1127                              <1> 
  1128                              <1>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
  1129                              <1> %idefine dual2function	dualfunction
  1130                              <1> %idefine dual2return	dualreturn
  1131                              <1> %idefine dual2distance	dualdistance
  1132                              <1> %idefine dual2call	dualcall
  1133                              <1>  %else
  1134                              <1> %idefine dual2function comment
  1135                              <1> %idefine dual2return
  1136                              <1> %idefine dual2distance near
  1137                              <1> 	%imacro dual2call 1.nolist
  1138                              <1> 	call %1
  1139                              <1> 	%endmacro
  1140                              <1>  %endif
  1141                              <1> 
  1142                              <1> 
  1143                              <1> 	numdef CHECKSECTION, 0
  1144                              <1> 	numdef CHECKCALLSECTION, _CHECKSECTION
  1145                              <1> 	numdef CHECKJMPSECTION, _CHECKSECTION
  1146                              <1> 	numdef CHECKJCCSECTION, _CHECKSECTION
  1147                              <1> 
  1148                              <1> %if _CHECKCALLSECTION
  1149                              <1> 	%imacro call 1.nolist
  1150                              <1> 	%? %1
  1151                              <1> checksection %1, %?, call
  1152                              <1> 	%endmacro
  1153                              <1> %endif
  1154                              <1> %if _CHECKJMPSECTION
  1155                              <1> 	%imacro jmp 1.nolist
  1156                              <1> 	%? %1
  1157                              <1> checksection %1, %?, jmp
  1158                              <1> 	%endmacro
  1159                              <1> %endif
  1160                              <1> %if _CHECKJCCSECTION
  1161                              <1> 	%imacro je 1.nolist
  1162                              <1> 	%? %1
  1163                              <1> checksection %1, %?, jcc
  1164                              <1> 	%endmacro
  1165                              <1> 	%imacro jne 1.nolist
  1166                              <1> 	%? %1
  1167                              <1> checksection %1, %?, jcc
  1168                              <1> 	%endmacro
  1169                              <1> 	%imacro jz 1.nolist
  1170                              <1> 	%? %1
  1171                              <1> checksection %1, %?, jcc
  1172                              <1> 	%endmacro
  1173                              <1> 	%imacro jnz 1.nolist
  1174                              <1> 	%? %1
  1175                              <1> checksection %1, %?, jcc
  1176                              <1> 	%endmacro
  1177                              <1> 
  1178                              <1> 	%imacro jb 1.nolist
  1179                              <1> 	%? %1
  1180                              <1> checksection %1, %?, jcc
  1181                              <1> 	%endmacro
  1182                              <1> 	%imacro jnb 1.nolist
  1183                              <1> 	%? %1
  1184                              <1> checksection %1, %?, jcc
  1185                              <1> 	%endmacro
  1186                              <1> 	%imacro jbe 1.nolist
  1187                              <1> 	%? %1
  1188                              <1> checksection %1, %?, jcc
  1189                              <1> 	%endmacro
  1190                              <1> 	%imacro jnbe 1.nolist
  1191                              <1> 	%? %1
  1192                              <1> checksection %1, %?, jcc
  1193                              <1> 	%endmacro
  1194                              <1> 	%imacro jc 1.nolist
  1195                              <1> 	%? %1
  1196                              <1> checksection %1, %?, jcc
  1197                              <1> 	%endmacro
  1198                              <1> 	%imacro jnc 1.nolist
  1199                              <1> 	%? %1
  1200                              <1> checksection %1, %?, jcc
  1201                              <1> 	%endmacro
  1202                              <1> 	%imacro ja 1.nolist
  1203                              <1> 	%? %1
  1204                              <1> checksection %1, %?, jcc
  1205                              <1> 	%endmacro
  1206                              <1> 	%imacro jna 1.nolist
  1207                              <1> 	%? %1
  1208                              <1> checksection %1, %?, jcc
  1209                              <1> 	%endmacro
  1210                              <1> 	%imacro jae 1.nolist
  1211                              <1> 	%? %1
  1212                              <1> checksection %1, %?, jcc
  1213                              <1> 	%endmacro
  1214                              <1> 	%imacro jnae 1.nolist
  1215                              <1> 	%? %1
  1216                              <1> checksection %1, %?, jcc
  1217                              <1> 	%endmacro
  1218                              <1> 
  1219                              <1> 	%imacro jl 1.nolist
  1220                              <1> 	%? %1
  1221                              <1> checksection %1, %?, jcc
  1222                              <1> 	%endmacro
  1223                              <1> 	%imacro jnl 1.nolist
  1224                              <1> 	%? %1
  1225                              <1> checksection %1, %?, jcc
  1226                              <1> 	%endmacro
  1227                              <1> 	%imacro jle 1.nolist
  1228                              <1> 	%? %1
  1229                              <1> checksection %1, %?, jcc
  1230                              <1> 	%endmacro
  1231                              <1> 	%imacro jnle 1.nolist
  1232                              <1> 	%? %1
  1233                              <1> checksection %1, %?, jcc
  1234                              <1> 	%endmacro
  1235                              <1> 	%imacro jg 1.nolist
  1236                              <1> 	%? %1
  1237                              <1> checksection %1, %?, jcc
  1238                              <1> 	%endmacro
  1239                              <1> 	%imacro jng 1.nolist
  1240                              <1> 	%? %1
  1241                              <1> checksection %1, %?, jcc
  1242                              <1> 	%endmacro
  1243                              <1> 	%imacro jge 1.nolist
  1244                              <1> 	%? %1
  1245                              <1> checksection %1, %?, jcc
  1246                              <1> 	%endmacro
  1247                              <1> 	%imacro jnge 1.nolist
  1248                              <1> 	%? %1
  1249                              <1> checksection %1, %?, jcc
  1250                              <1> 	%endmacro
  1251                              <1> 
  1252                              <1> 	%imacro jo 1.nolist
  1253                              <1> 	%? %1
  1254                              <1> checksection %1, %?, jcc
  1255                              <1> 	%endmacro
  1256                              <1> 	%imacro jno 1.nolist
  1257                              <1> 	%? %1
  1258                              <1> checksection %1, %?, jcc
  1259                              <1> 	%endmacro
  1260                              <1> 	%imacro jp 1.nolist
  1261                              <1> 	%? %1
  1262                              <1> checksection %1, %?, jcc
  1263                              <1> 	%endmacro
  1264                              <1> 	%imacro jnp 1.nolist
  1265                              <1> 	%? %1
  1266                              <1> checksection %1, %?, jcc
  1267                              <1> 	%endmacro
  1268                              <1> 	%imacro jpe 1.nolist
  1269                              <1> 	%? %1
  1270                              <1> checksection %1, %?, jcc
  1271                              <1> 	%endmacro
  1272                              <1> 	%imacro jnpe 1.nolist
  1273                              <1> 	%? %1
  1274                              <1> checksection %1, %?, jcc
  1275                              <1> 	%endmacro
  1276                              <1> 	%imacro jpo 1.nolist
  1277                              <1> 	%? %1
  1278                              <1> checksection %1, %?, jcc
  1279                              <1> 	%endmacro
  1280                              <1> 	%imacro jnpo 1.nolist
  1281                              <1> 	%? %1
  1282                              <1> checksection %1, %?, jcc
  1283                              <1> 	%endmacro
  1284                              <1> 	%imacro js 1.nolist
  1285                              <1> 	%? %1
  1286                              <1> checksection %1, %?, jcc
  1287                              <1> 	%endmacro
  1288                              <1> 	%imacro jns 1.nolist
  1289                              <1> 	%? %1
  1290                              <1> checksection %1, %?, jcc
  1291                              <1> 	%endmacro
  1292                              <1> 
  1293                              <1> 	%imacro jcxz 1.nolist
  1294                              <1> 	%? %1
  1295                              <1> checksection %1, %?, jcc
  1296                              <1> 	%endmacro
  1297                              <1> 	%imacro jecxz 1.nolist
  1298                              <1> 	%? %1
  1299                              <1> checksection %1, %?, jcc
  1300                              <1> 	%endmacro
  1301                              <1> 	%imacro loop 1.nolist
  1302                              <1> 	%? %1
  1303                              <1> checksection %1, %?, jcc
  1304                              <1> 	%endmacro
  1305                              <1> 	%imacro loopz 1.nolist
  1306                              <1> 	%? %1
  1307                              <1> checksection %1, %?, jcc
  1308                              <1> 	%endmacro
  1309                              <1> 	%imacro loopnz 1.nolist
  1310                              <1> 	%? %1
  1311                              <1> checksection %1, %?, jcc
  1312                              <1> 	%endmacro
  1313                              <1> 	%imacro loope 1.nolist
  1314                              <1> 	%? %1
  1315                              <1> checksection %1, %?, jcc
  1316                              <1> 	%endmacro
  1317                              <1> 	%imacro loopne 1.nolist
  1318                              <1> 	%? %1
  1319                              <1> checksection %1, %?, jcc
  1320                              <1> 	%endmacro
  1321                              <1> %endif
  1322                              <1> 
  1323                              <1> 	%imacro checksection 3.nolist
  1324                              <1> %push
  1325                              <1>  %defstr %$string %1
  1326                              <1>  %substr %$shortword %$string 1, 5
  1327                              <1>  %substr %$shortsep %$string 6, 1
  1328                              <1>  %substr %$nearword %$string 1, 4
  1329                              <1>  %substr %$nearsep %$string 5, 1
  1330                              <1>  %substr %$farword %$string 1, 3
  1331                              <1>  %substr %$farsep %$string 4, 1
  1332                              <1>  %assign %$isshort 0
  1333                              <1>  %ifidni %$shortword, "short"
  1334                              <1>   %if %$shortsep == 32 || %$shortsep == 9
  1335                              <1>    %assign %$isshort 1
  1336                              <1>    %substr %$string %$string 7, -1
  1337                              <1>   %elif %$shortsep == '['
  1338                              <1>    %assign %$isshort 1
  1339                              <1>    %substr %$string %$string 6, -1
  1340                              <1>   %endif
  1341                              <1>  %endif
  1342                              <1>  %assign %$isnear 0
  1343                              <1>  %ifidni %$nearword, "near"
  1344                              <1>   %if %$nearsep == 32 || %$nearsep == 9
  1345                              <1>    %assign %$isnear 1
  1346                              <1>    %substr %$string %$string 6, -1
  1347                              <1>   %elif %$nearsep == '['
  1348                              <1>    %assign %$isnear 1
  1349                              <1>    %substr %$string %$string 5, -1
  1350                              <1>   %endif
  1351                              <1>  %endif
  1352                              <1>  %assign %$isfar 0
  1353                              <1>  %ifidni %$farword, "far"
  1354                              <1>   %if %$farsep == 32 || %$farsep == 9
  1355                              <1>    %assign %$isfar 1
  1356                              <1>    %substr %$string %$string 5, -1
  1357                              <1>   %elif %$farsep == '['
  1358                              <1>    %assign %$isfar 1
  1359                              <1>    %substr %$string %$string 4, -1
  1360                              <1>   %endif
  1361                              <1>  %endif
  1362                              <1> 
  1363                              <1>  %deftok %$token %$string
  1364                              <1> 
  1365                              <1>  %assign %$size 2
  1366                              <1>  %assign %$isreg 0
  1367                              <1>  %assign %$exit 0
  1368                              <1>  %rep 2
  1369                              <1>   %ifn %$exit
  1370                              <1>    %if %$size == 2
  1371                              <1>     %define %$regnames "ax  cx  dx  bx  sp  bp  si  di  "
  1372                              <1>    %elif %$size == 4
  1373                              <1>     %define %$regnames "eax ecx edx ebx esp ebp esi edi "
  1374                              <1>    %endif
  1375                              <1>    %assign %$index 0
  1376                              <1>    %rep 8
  1377                              <1>     %ifn %$exit
  1378                              <1>      %substr %$reg %$regnames %$index * 4 + 1, 4
  1379                              <1>      %deftok %$reg %$reg
  1380                              <1>      %ifnempty %$reg
  1381                              <1>       %ifidni %$reg, %$token
  1382                              <1>        %assign %$isreg %$size
  1383                              <1>        %assign %$exit 1
  1384                              <1>        %exitrep
  1385                              <1>       %endif
  1386                              <1>      %endif
  1387                              <1>     %endif
  1388                              <1>     %assign %$index %$index + 1
  1389                              <1>    %endrep
  1390                              <1>    %if %$exit
  1391                              <1>     %exitrep
  1392                              <1>    %endif
  1393                              <1>    %assign %$size %$size * 2
  1394                              <1>   %endif
  1395                              <1>  %endrep
  1396                              <1> 
  1397                              <1>  %assign %$ismulti 0
  1398                              <1>  %assign %$ismem 0
  1399                              <1>  %strlen %$length %$string
  1400                              <1>  %assign %$ii 0
  1401                              <1>  %rep %$length
  1402                              <1>   %substr %$point %$string %$ii + 1, 1
  1403                              <1>   %if %$point == 32 || %$point == 9
  1404                              <1>    %assign %$ismulti 1
  1405                              <1>   %endif
  1406                              <1>   %ifidn %$point, '['
  1407                              <1>    %assign %$ismem 1
  1408                              <1>   %endif
  1409                              <1>   %assign %$ii %$ii + 1
  1410                              <1>  %endrep
  1411                              <1> 
  1412                              <1>  %assign %$islocal 0
  1413                              <1>  %substr %$point %$string 1, 1
  1414                              <1>  %substr %$prefix %$string 1, 3
  1415                              <1>  %ifidn %$point, '.'
  1416                              <1>   %ifnidn %$prefix, '..@'
  1417                              <1>    %assign %$islocal 1
  1418                              <1>   %endif
  1419                              <1>  %endif
  1420                              <1> 
  1421                              <1>  %if %$isreg
  1422                              <1>   %if %$isreg == 4
  1423                              <1>    %warning 32-bit reg %3: %2 %1
  1424                              <1>   %else
  1425                              <1>    %warning 16-bit reg %3: %2 %1
  1426                              <1>   %endif
  1427                              <1>  %elif %$ismulti || %$ismem
  1428                              <1>   %warning not single %3: %2 %1
  1429                              <1>  %elif %$islocal
  1430                              <1>   %ifidni %3, call
  1431                              <1>    %warning local %3: %2 %1
  1432                              <1>   %endif
  1433                              <1>  %elifdef SECTION_OF_%[%$token]
  1434                              <1>   %ifnidni SECTION_OF_%[%$token], _CURRENT_SECTION
  1435                              <1>    %error Symbol %$token called wrongly: section_of=SECTION_OF_%[%$token], current=_CURRENT_SECTION
  1436                              <1>   %endif
  1437                              <1>  %endif
  1438                              <1> %pop
  1439                              <1> 	%endmacro
  1440                              <1> 
  1441                              <1> 
  1442                              <1> 	struc MEMREF
  1443 00000000 ????????            <1> mrLinear:		resd 1
  1444 00000004 ????????            <1> mrOffset:		resd 1
  1445 00000008 ????                <1> mrSegmentSelector:	resw 1
  1446 0000000A ????                <1> mrFlags:		resw 1
  1447 0000000C ????????            <1> mrLength:		resd 1
  1448                              <1> 	endstruc
  1449                              <1> 
  1450                              <1> 		; Currently only direct branches are allowed when
  1451                              <1> 		;  disassembling from the U command. (That is,
  1452                              <1> 		;  [disflags] & DIS_F_SHOW is clear.) All other
  1453                              <1> 		;  types of references depend on segment registers
  1454                              <1> 		;  and sometimes base and index registers, which are
  1455                              <1> 		;  not known ahead of time. They are only known for
  1456                              <1> 		;  the R command's disassembly. (DIS_F_SHOW set.)
  1457                              <1> 		; (When a mov ss or pop to ss will change ss, a
  1458                              <1> 		;  subsequent instruction using ss will not be
  1459                              <1> 		;  disassembled with the correct ss value.
  1460                              <1> 		;  This should be rare though. We may at a later
  1461                              <1> 		;  point detect this condition and not display
  1462                              <1> 		;  references with ss then.)
  1463                              <1> mrfBranchDirect:	equ    1
  1464                              <1> mrfMem:			equ    2
  1465                              <1> mrfMemSource:		equ    4
  1466                              <1> mrfMemDest:		equ    8
  1467                              <1> mrfA32:			equ   10h
  1468                              <1> mrfString:		equ   20h
  1469                              <1> mrfStringSource:	equ   40h
  1470                              <1> mrfStringDest:		equ   80h
  1471                              <1> mrfUsesSS:		equ  100h
  1472                              <1> mrfBranchIndirect:	equ  200h
  1473                              <1> 
  1474                              <1> 
  1475                              <1> %if _VXCHG && ! _VXCHGBIOS
  1476                              <1> 	struc XMSM
  1477 00000000 ????????            <1> .size_:		resd 1
  1478 00000004 ????                <1> .srchdl:	resw 1
  1479 00000006 ????????            <1> .srcadr:	resd 1
  1480 0000000A ????                <1> .dsthdl:	resw 1
  1481 0000000C ????????            <1> .dstadr:	resd 1
  1482                              <1> 	endstruc
  1483                              <1> %endif
  1484                              <1> 
  1485                              <1> 
  1486                              <1> 	; doscall is used by symbols.asm and run.asm and in
  1487                              <1> 	;  cmd3_close_handle, so define it prior
  1488                              <1> %if _PM && _NOEXTENDER
  1489                              <1> %macro doscall 0
  1490                              <1> 	nearcall _doscall
  1491                              <1> %endmacro
  1492                              <1> %else
  1493                              <1> 		; When we don't support non-extended DPMI all Int21 calls
  1494                              <1> 		; are either in Real Mode or extended (all are real Int21
  1495                              <1> 		; instructions).
  1496                              <1> %macro doscall 0
  1497                              <1> 	int 21h
  1498                              <1> %endmacro
  1499                              <1> %endif
  1500                              <1> 
  1501                              <1> 
  1502                              <1> %if _LINK
  1503                              <1> %imacro wlcalc 1-2.nolist
  1504                              <1> %deftok %%filenametoken __FILE__
  1505                              <1>  global wlcalc_%1?%[%%l]%[%%filenametoken]
  1506                              <1> wlcalc_%1?%[%%l]%[%%filenametoken]: %2
  1507                              <1> %endmacro
  1508                              <1> %endif
  1509                              <1> 
  1510                              <1> %if _BOOTLDR && _LINK
  1511                              <1> %macro lot_equate 2.nolist
  1512                              <1> LOAD_%2 equ %1
  1513                              <1> %endmacro
  1514                              <1> 
  1515                              <1> 	lot_equate    1, SET_DL_UNIT
  1516                              <1> 	lot_equate    2, SET_BL_UNIT
  1517                              <1> 	lot_equate    4, SET_SIDI_CLUSTER
  1518                              <1> 	lot_equate  10h, SET_DSSI_DPT
  1519                              <1> 	lot_equate  20h, PUSH_DPT
  1520                              <1> 	lot_equate  40h, DATASTART_HIDDEN
  1521                              <1> 	lot_equate  80h, SET_AXBX_DATASTART
  1522                              <1> 	lot_equate 100h, SET_DSBP_BPB
  1523                              <1> 	lot_equate 200h, LBA_SET_TYPE
  1524                              <1> 	lot_equate 400h, MESSAGE_TABLE
  1525                              <1> 	lot_equate 800h, SET_AXBX_ROOT_HIDDEN
  1526                              <1> 	lot_equate 1000h, CMDLINE
  1527                              <1> 	lot_equate 2000h, NO_BPB
  1528                              <1> 	lot_equate 4000h, SET_DSSI_PARTINFO
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> %if _HELP_COMPRESSED
  1532                              <1>  %assign NONCOMPRESSEDFLAG 1
  1533                              <1> %else
  1534                              <1>  %assign NONCOMPRESSEDFLAG 0
  1535                              <1> %endif
  1536                              <1> 
  1537                              <1> [list +]
  1538                              <1> 
  1539                              <1> %if _LINK
  1540                              <1>  %if _ONLY386
  1541                              <1> 	cpu 386
  1542                              <1>  %else
  1543                              <1> 	cpu 8086
  1544                              <1>  %endif
  1545                              <1> 
  1546                              <1> auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  1547                              <1> 	endarea auxbuff, 1
  1548                              <1> 
  1549                              <1> auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1550                              <1> 	endarea auxbuff_max, 1
  1551                              <1> 
  1552                              <1> %if _INIT_MAX
  1553                              <1>  auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  1554                              <1> %else
  1555                              <1>  auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  1556                              <1> %endif
  1557                              <1> 	endarea auxbuff_init, 1
  1558                              <1> 
  1559                              <1>  %include "options.mac"
     1                              <2> 
     2                              <2> %if 0
     3                              <2> 
     4                              <2> lDebug options and internal flags
     5                              <2> 
     6                              <2> Copyright (C) 2008-2025 E. C. Masloch
     7                              <2> 
     8                              <2> Usage of the works is permitted provided that this
     9                              <2> instrument is retained with the works, so that any entity
    10                              <2> that uses the works is notified of this instrument.
    11                              <2> 
    12                              <2> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <2> 
    14                              <2> %endif
    15                              <2> 
    16                              <2> 
    17                              <2> dispregs32	equ	  1	; RX: 32-bit register display (R, T/P/G)
    18                              <2> traceints	equ	  2	; TM: trace into interrupts (T)
    19                              <2> cpdepchars	equ	  4	; allow dumping of CP-dependent characters (D, DX)
    20                              <2> fakeindos	equ	  8	; always assume InDOS flag non-zero (all)
    21                              <2> nonpagingdevice	equ	 10h	; disallow paged output with [more] prompt (all exc. P, T)
    22                              <2> 	; This option was never used anywhere:
    23                              <2> ; pagingdevice	equ	 20h	; allow paged output with [more] prompt (all exc. P, T)
    24                              <2> 				; paged output is by default on if the output device is StdOut, else off
    25                              <2> hexrn		equ	 40h	; display raw hexadecimal content of FPU registers (RN)
    26                              <2> ;novdd		equ	 80h	; don't use a registered NTVDM VDD (L, W)
    27                              <2> nondospaging	equ	100h	; paging: don't use DOS for input when waiting for a key
    28                              <2> opt1_86mnohlt	equ	200h	; (86 Mode:) HLT doesn't work, don't use it
    29                              <2> biosidles	equ	400h	; don't idle with HLT or Int2F.1680, only call BIOS Int16.00
    30                              <2> opt_usegetinput	equ	800h	; use getinput for int 21h interactive input
    31                              <2> use_si_units	equ    1000h	; in disp_*_size use SI units (kB = 1000, etc)
    32                              <2> use_jedec_units	equ    2000h	; in disp_*_size use JEDEC units (kB = 1024)
    33                              <2> enable_serial	equ    4000h	; enable serial I/O (preferred over DOS or BIOS terminal)
    34                              <2> int8_disable_serial equ	   8000h	; disable serial I/O when breaking due to intr8
    35                              <2> gg_do_not_skip_bp equ	 1_0000h	; gg: do not skip a breakpoint (bb or gg)
    36                              <2> gg_no_autorepeat equ	 2_0000h	; gg: do not auto-repeat
    37                              <2> tp_do_not_skip_bp equ	 4_0000h	; T/TP/P: do not skip a (bb) breakpoint
    38                              <2> gg_bb_hit_no_repeat equ	 8_0000h	; gg: do not auto-repeat after bb hit
    39                              <2> tp_bb_hit_no_repeat equ	10_0000h	; T/TP/P: do not auto-repeat after bb hit
    40                              <2> gg_unexpected_no_repeat equ 20_0000h	; gg: do not auto-repeat after unexpectedinterrupt
    41                              <2> tp_unexpected_no_repeat equ 40_0000h	; T/TP/P
    42                              <2> ss_no_dump:		equ 80_0000h
    43                              <2> %if _SYMBOLIC
    44                              <2> dd_no_blanks_sym:	equ 100_0000h
    45                              <2> zz_no_pm_xms:		equ 200_0000h
    46                              <2> %endif
    47                              <2> rr_disasm_no_rept:	equ 1000_0000h
    48                              <2> rr_disasm_no_show:	equ 2000_0000h
    49                              <2> opt_cmdline_quiet_input:equ 4000_0000h
    50                              <2> opt_cmdline_quiet_output:equ 8000_0000h
    51                              <2> %if _SYMBOLIC
    52                              <2> DEFAULTOPTIONS	equ zz_no_pm_xms
    53                              <2> %else
    54                              <2> DEFAULTOPTIONS	equ 0
    55                              <2> %endif
    56                              <2> 
    57                              <2> 
    58                              <2> opt2_db_header:		equ 1
    59                              <2> opt2_db_trailer:	equ 2
    60                              <2> opt2_dw_header:		equ 10h
    61                              <2> opt2_dw_trailer:	equ 20h
    62                              <2> opt2_dd_header:		equ 100h
    63                              <2> opt2_dd_trailer:	equ 200h
    64                              <2> opt2_getinput_dpmi:	equ 800h
    65                              <2> opt2_hh_compat:		equ 1000h
    66                              <2> opt2_getc_idle:		equ 2000h
    67                              <2> opt2_getc_idle_dpmi:	equ 4000h
    68                              <2> opt2_re_cancel_tpg:	equ 8000h
    69                              <2> opt2_nn_compat:		equ 1_0000h
    70                              <2> opt2_nn_capitalise:	equ 2_0000h
    71                              <2> %if _MS_0RANGE_COMPAT
    72                              <2> opt2_0range_compat:	equ 4_0000h
    73                              <2> %endif
    74                              <2> opt2_rr16_compat:	equ 8_0000h
    75                              <2> opt2_r_prompt_compat:	equ 10_0000h
    76                              <2> opt2_r_separate:	equ 20_0000h
    77                              <2> opt2_r_linebreak_always:equ 40_0000h
    78                              <2> opt2_dpminohlt:		equ 8000_0000h	; DPMI doesn't like hlt
    79                              <2> DEFAULTOPTIONS2	equ opt2_dw_header | opt2_dd_header | opt2_getc_idle_dpmi | opt2_dpminohlt
    80                              <2> 
    81                              <2> 
    82                              <2> opt3_tt_no_paging:	equ 1
    83                              <2> opt3_tp_no_paging:	equ 2
    84                              <2> opt3_pp_no_paging:	equ 4
    85                              <2> opt3_gg_no_paging:	equ 8
    86                              <2> opt3_silence_paging_set:equ 100h
    87                              <2> opt3_silence_paging_on:	equ 200h
    88                              <2> opt3_paging_rc:		equ 1000h
    89                              <2> opt3_paging_yy:		equ 2000h
    90                              <2> opt3_paging_re:		equ 4000h
    91                              <2> opt3_r_highlight_diff:	equ 10000h
    92                              <2> opt3_r_highlight_dumb:	equ 20000h
    93                              <2> opt3_r_highlight_full:	equ 40000h
    94                              <2> opt3_r_highlight_eip:	equ 80000h
    95                              <2> %if _PM
    96                              <2> opt3_ss_b_bit_set:	equ   10_0000h
    97                              <2>  %if _BREAK_INSTALLDPMI
    98                              <2> opt3_break_installdpmi:	equ   20_0000h
    99                              <2>  %endif
   100                              <2> %endif
   101                              <2> %if _DHIGHLIGHT
   102                              <2> opt3_d_highlight:	equ   80_0000h
   103                              <2> %endif
   104                              <2> %if _GETLINEHIGHLIGHT
   105                              <2> opt3_getline_highlight:	equ  100_0000h
   106                              <2> %endif
   107                              <2> opt3_no_idle_2F:	equ  200_0000h
   108                              <2> %if _DELAY_BEFORE_BP
   109                              <2> opt3_delay_before_bp:	equ  400_0000h
   110                              <2> %endif
   111                              <2> opt3_no_call_amis:	equ  800_0000h
   112                              <2> opt3_disable_autorepeat:equ 1000_0000h
   113                              <2> opt3_check_ctrlc_keyb:	equ 2000_0000h
   114                              <2> opt3_check_ctrlc_0bh:	equ 4000_0000h
   115                              <2> opt3_tsr_quit_leave_tf:	equ 8000_0000h
   116                              <2> DEFAULTOPTIONS3	equ opt3_tt_no_paging | opt3_tp_no_paging 		| opt3_pp_no_paging | opt3_gg_no_paging 		| opt3_check_ctrlc_keyb | opt3_check_ctrlc_0bh
   119                              <2> 
   120                              <2> 
   121                              <2> opt4_int_2F_hook:	equ 2
   122                              <2> opt4_int_08_hook:	equ 4
   123                              <2> opt4_int_2D_hook:	equ 8
   124                              <2> %if _CATCHINTFAULTCOND
   125                              <2> opt4_int_fault_hook:	equ 10h
   126                              <2> %endif
   127                              <2> opt4_int_serial_force:	equ 1_0000h
   128                              <2> opt4_int_2F_force:	equ 2_0000h
   129                              <2> opt4_int_08_force:	equ 4_0000h
   130                              <2> opt4_int_2D_force:	equ 8_0000h
   131                              <2> %if _CATCHINT0D
   132                              <2> opt4_int_0D_force:	equ   10_0000h
   133                              <2> %endif
   134                              <2> %if _CATCHINT0C
   135                              <2> opt4_int_0C_force:	equ   20_0000h
   136                              <2> %endif
   137                              <2> opt4_int_00_force:	equ  100_0000h
   138                              <2> opt4_int_01_force:	equ  200_0000h
   139                              <2> opt4_int_03_force:	equ  400_0000h
   140                              <2> opt4_int_06_force:	equ  800_0000h
   141                              <2> opt4_int_18_force:	equ 1000_0000h
   142                              <2> opt4_int_19_force:	equ 2000_0000h
   143                              <2> opt4_int_09_force:	equ 4000_0000h	; not used at the same time as 15h
   144                              <2> opt4_int_15_force:	equ 4000_0000h	; not used at the same time as 09h
   145                              <2> opt4_int_07_force:	equ 8000_0000h
   146                              <2> DEFAULTOPTIONS4 equ opt4_int_2F_hook
   147                              <2> 
   148                              <2> 
   149                              <2> %if _VXCHG
   150                              <2> opt6_vv_mode:		equ 1
   151                              <2> opt6_vv_keep:		equ 2
   152                              <2> opt6_vv_int16:		equ 10h
   153                              <2>  %if _VXCHG_DEFAULT_ON
   154                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq | opt6_vv_mode
   155                              <2>  %else
   156                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   157                              <2>  %endif
   158                              <2> %else
   159                              <2> DEFAULTOPTIONS6 equ opt6_share_serial_irq
   160                              <2> %endif
   161                              <2> %if _DEBUG
   162                              <2> opt6_debug_exception_late:	equ  20h
   163                              <2> opt6_debug_exception_early:	equ  40h
   164                              <2>  %if _DEBUG_COND
   165                              <2> opt6_debug_exception:	equ  80h
   166                              <2> opt6_debug_mode:	equ 100h
   167                              <2>  %endif
   168                              <2> %endif
   169                              <2> opt6_bios_output:	equ 200h
   170                              <2> opt6_flat_binary:	equ 400h
   171                              <2> opt6_big_stack:		equ 800h
   172                              <2> opt6_40_columns:	equ 1000h
   173                              <2> opt6_40_indent_odd:	equ 2000h
   174                              <2> opt6_40_dash:		equ 4000h
   175                              <2> opt6_share_serial_irq:	equ 1_0000h
   176                              <2> opt6_serial_EOI_call:	equ 2_0000h
   177                              <2> %if _RH
   178                              <2> opt6_rh_mode:		equ 10_0000h
   179                              <2> %endif
   180                              <2> %if _DEBUG
   181                              <2> opt6_debug_putrunint_early:	equ  40_0000h
   182                              <2>  %if _DEBUG_COND
   183                              <2> opt6_debug_putrunint:		equ  80_0000h
   184                              <2>  %endif
   185                              <2> %endif
   186                              <2> opt6_bios_io:		equ 100_0000h
   187                              <2> opt6_immasm_display_uu:	equ 200_0000h
   188                              <2> opt6_immasm_debug:	equ 400_0000h
   189                              <2> opt6_immasm_flag:	equ 800_0000h
   190                              <2> opt6_immasm_nobranch:	equ 1000_0000h
   191                              <2> opt6_r_flags_style2:	equ 2000_0000h
   192                              <2> opt6_r_flags_style3:	equ 4000_0000h
   193                              <2> opt6_r_linebreak_conditional:	equ 8000_0000h
   194                              <2> 
   195                              <2> 
   196                              <2> DEFAULTOPTIONS7 equ opt7_no_tsr_ll
   197                              <2> opt7_no_free_oneshot_eld:	equ 1
   198                              <2> opt7_debug_optional_link:	equ 2
   199                              <2> opt7_quiet_install:		equ 4
   200                              <2> opt7_quick_run:			equ 8
   201                              <2> opt7_houdini:			equ 100h
   202                              <2> opt7_debug_run:			equ 200h
   203                              <2> opt7_no_ensure:			equ 1000h
   204                              <2> opt7_no_tsr_ll:			equ 2000h
   205                              <2> 
   206                              <2> 
   207                              <2> oldpacket	equ	  1	; Int25/Int26 packet method available (L, W)
   208                              <2> newpacket	equ	  2	; Int21.7305 packet method available (L, W)
   209                              <2> ntpacket	equ	  4	; VDD registered and usable (L, W)
   210                              <2> pagedcommand	equ	  8	; allows paging in puts
   211                              <2> notstdinput	equ	 10h	; DEBUG's StdIn isn't a device with StdIn bit (is file or other device)
   212                              <2> inputfile	equ	 20h	; DEBUG's StdIn is a file, notstdinput also set
   213                              <2> notstdoutput	equ	 40h	; DEBUG's StdOut isn't a device with StdOut bit (is file or other device)
   214                              <2> outputfile	equ	  80h	; DEBUG's StdOut is a file, notstdoutput also set
   215                              <2> hooked2F	equ	 100h	; Int2F hooked
   216                              <2> nohook2F	equ	 200h	; don't hook Int2F.1687 (required for Win9x, DosEmu?)
   217                              <2> unused_dif1_dpminohlt equ 400h	; DPMI doesn't like hlt
   218                              <2> protectedmode	equ	 800h	; in (DPMI) protected mode
   219                              <2> debuggeeA20	equ	1000h	; state of debuggee's A20
   220                              <2> debuggerA20	equ	2000h	; state of debugger's A20 (will be on if possible)
   221                              <2> nodosloaded	equ	4000h	; No DOS loaded currently (Boot loader mode)
   222                              <2> has386		equ	8000h	; CPU is a 386
   223                              <2> usecharcounter	equ    1_0000h	; don't reset charcounter between calls to puts
   224                              <2> runningnt	equ    2_0000h	; running in NTVDM
   225                              <2> canswitchmode	equ    4_0000h	; can switch modes (auxbuff large enough, DPMI mode switch set up)
   226                              <2> modeswitched	equ    8_0000h	; switched mode (now in the mode that we weren't entered in)
   227                              <2> promptwaiting	equ   10_0000h	; puts: any more output needs to display a prompt first
   228                              <2> switchbuffer	equ   20_0000h	; mode switch needs a buffer (auxbuff)
   229                              <2> tsrmode		equ   40_0000h	; in TSR mode; DPI and DPP not valid
   230                              <2> attachedterm	equ   80_0000h	; the attached process terminated
   231                              <2> runningdosemu	equ  100_0000h	; running in dosemu
   232                              <2> ; load_is_ldp	equ  200_0000h	; boot load: partition specified as "ldp"
   233                              <2> tt_while:	equ  400_0000h	; tt: while condition specified
   234                              <2> tt_p:		equ  800_0000h	; tt: proceed past repeated string instructions
   235                              <2> tt_silent_mode:	equ 1000_0000h	; tt: run should be silent (dump at end)
   236                              <2> tt_silence:	equ 2000_0000h	; tt: silent writing (write to auxbuff instead)
   237                              <2> tt_no_bb:	equ 4000_0000h	; tt: do not use bb breakpoints
   238                              <2> tt_no_bb_first:	equ 8000_0000h	; tt: do not use bb breakpoints at first
   239                              <2> 
   240                              <2> 
   241                              <2> dif2_gg_is_first:	equ   1
   242                              <2> dif2_gg_skip_non_cseip:	equ   2
   243                              <2> dif2_gg_skip_cseip:	equ   4
   244                              <2> dif2_gg_is_gg:		equ   8
   245                              <2> dif2_gg_first_detected:	equ  10h
   246                              <2> dif2_gg_again:		equ  20h
   247                              <2> dif2_tpg_proceed_bp_set:equ  40h
   248                              <2> dif2_tpg_keep_proceed_bp: equ 80h
   249                              <2> dif2_tpg_have_bp:	equ 100h
   250                              <2> dif2_tpg_adjusted_cseip:equ 200h
   251                              <2> dif2_tpg_do_not_adjust:	equ 400h
   252                              <2> dif2_bp_failure:	equ 800h
   253                              <2> dif2_is_pp:		equ 1000h
   254                              <2> %if _SYMBOLIC
   255                              <2> dif2_createdprocess:	equ 800_0000h	; created empty debuggee process
   256                              <2> dif2_sym_req_xms:	equ 2000h
   257                              <2> dif2_sym_req_86mm:	equ 4000h
   258                              <2> dif2_sym_req_mask equ dif2_sym_req_86mm | dif2_sym_req_xms
   259                              <2> dif2_no_pm_xms:		equ 1_0000h
   260                              <2> dif2_xms_detection_done:equ 2_0000h
   261                              <2> %endif
   262                              <2> %if _INPUT_FILE_HANDLES
   263                              <2> dif2_input_file:	equ 10_0000h
   264                              <2> dif2_closed_input_file:	equ 20_0000h
   265                              <2> %endif
   266                              <2> dif2_did_getline_file:	equ 40_0000h
   267                              <2> %if _SYMBOLIC
   268                              <2> dif2_poison:		equ 80_0000h
   269                              <2> %endif
   270                              <2> dif2_boot_loaded_kernel:equ 100_0000h
   271                              <2> %if _INPUT_FILE_BOOT
   272                              <2> dif2_input_file_boot:	equ 200_0000h
   273                              <2> dif2_closed_input_file_boot:	equ 400_0000h
   274                              <2> %endif
   275                              <2> dif2_in_silence_dump:	equ 1000_0000h
   276                              <2> dif2_int31_segment:	equ 2000_0000h
   277                              <2> dif2_nn_compat:		equ 4000_0000h
   278                              <2> dif2_nn_capitalise:	equ 8000_0000h
   279                              <2> 
   280                              <2> 
   281                              <2> dif3_load_is_ldp:	equ 1	; boot load: partition specified as "ldp"
   282                              <2> dif3_load_is_sdp:	equ 2	; boot load: partition specified as "sdp"
   283                              <2> dif3_load_is_ydp:	equ 4	; boot load: partition specified as "ydp"
   284                              <2> dif3_load_is_dp:	equ dif3_load_is_ldp 				| dif3_load_is_sdp 				| dif3_load_is_ydp
   287                              <2> dif3_load_dir_dir:	equ 8
   288                              <2> dif3_input_terminal_override:	equ 10h
   289                              <2> dif3_input_serial_override:	equ 20h
   290                              <2> dif3_if_not:		equ 40h
   291                              <2> dif3_partition_changed:	equ 80h
   292                              <2> ;
   293                              <2> dif3_input_cmdline:	equ 100h; input reading from cmdline_buffer
   294                              <2> dif3_input_cmdline_closed: equ 200h
   295                              <2> dif3_at_line_end:	equ 400h
   296                              <2> dif3_quiet_input_single:equ 800h
   297                              <2> dif3_quiet_output:	equ 1000h
   298                              <2> dif3_unquiet_error:	equ 2000h
   299                              <2> dif3_unquiet_prompt:	equ 4000h
   300                              <2> dif3_unquiet:		equ dif3_unquiet_error | dif3_unquiet_prompt
   301                              <2> dif3_return_eof:	equ 8000h
   302                              <2> dif3_highlighting:	equ 1_0000h
   303                              <2> dif3_do_not_highlight:	equ 2_0000h
   304                              <2> dif3_int10_highlight:	equ 2_0000h
   305                              <2> dif3_nosymbols_1:	equ 4_0000h
   306                              <2> dif3_nosymbols_2:	equ 8_0000h
   307                              <2> %if _PM
   308                              <2> dif3_ss_b_bit_set:	equ  10_0000h
   309                              <2> %endif
   310                              <2> dif3_gotint19:		equ  20_0000h
   311                              <2> dif3_prior_pm:		equ  40_0000h
   312                              <2> %if _DELAY_BEFORE_BP
   313                              <2> dif3_delayed		equ  80_0000h
   314                              <2> %endif
   315                              <2> dif3_input_re:		equ 100_0000h	; input reading from re_buffer
   316                              <2> dif3_input_re_closed:	equ 200_0000h
   317                              <2> dif3_accept_getrange_0:	equ 400_0000h
   318                              <2> %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
   319                              <2> dif3_in_if:		equ 800_0000h
   320                              <2> %endif
   321                              <2> dif3_auxbuff_guarded_1:	equ 1000_0000h
   322                              <2> dif3_auxbuff_guarded_2:	equ 2000_0000h
   323                              <2> dif3_auxbuff_guarded_3:	equ 4000_0000h
   324                              <2> dif3_sss_is_reverse:	equ 8000_0000h
   325                              <2> 
   326                              <2> 
   327                              <2> dif4_int_serial_hooked:	equ 1
   328                              <2> dif4_int_2F_hooked:	equ 2
   329                              <2> dif4_int_08_hooked:	equ 4
   330                              <2> dif4_int_2D_hooked:	equ 8
   331                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0D
   332                              <2> dif4_int_0D_hooked:	equ 10h
   333                              <2> %endif
   334                              <2> %if _CATCHINTFAULTCOND && _CATCHINT0C
   335                              <2> dif4_int_0C_hooked:	equ 20h
   336                              <2> %endif
   337                              <2> %if _LOADER
   338                              <2> dif4_int_18_hooked:	equ 1000h
   339                              <2> dif4_int_19_hooked:	equ 2000h
   340                              <2> %endif
   341                              <2> 
   342                              <2> 
   343                              <2> %if _VXCHG
   344                              <2> dif6_vv_mode:		equ 1
   345                              <2> %endif
   346                              <2> dif6_in_hook2F:		equ 2
   347                              <2> dif6_in_amis_hook2F:	equ 4
   348                              <2> dif6_debug_mode:	equ 100h
   349                              <2> dif6_locked:		equ 200h
   350                              <2> dif6_mcp:		equ 400h
   351                              <2> %if _RH
   352                              <2> dif6_rh_mode_was:	equ  8_0000h
   353                              <2> dif6_rh_mode:		equ 10_0000h
   354                              <2> dif6_rh_mode_2:		equ 20_0000h
   355                              <2> %endif
   356                              <2> dif6_device_mode:	equ 40_0000h
   357                              <2> dif6_cpdepchars:	equ 80_0000h
   358                              <2> %if _IMMASM
   359                              <2> dif6_immasm_no_output:	equ 100_0000h
   360                              <2> dif6_immasm:		equ 200_0000h
   361                              <2> dif6_immasm_rel8:	equ 400_0000h
   362                              <2> %endif
   363                              <2> 
   364                              <2> 
   365                              <2> disasm_lowercase	equ 1
   366                              <2> disasm_commablank	equ 2
   367                              <2> disasm_nasm		equ 4
   368                              <2> disasm_lowercase_refmem:equ 8
   369                              <2> disasm_show_short:	equ 10h
   370                              <2> disasm_show_near:	equ 20h
   371                              <2> disasm_show_far:	equ 40h
   372                              <2> disasm_nec:		equ 80h
   373                              <2> disasm_40_columns:	equ 100h
   374                              <2> disasm_no_indent:	equ 200h
   375                              <2> disasm_msdebug_mnemonofs: equ 400h
   376                              <2> disasm_a16_memref:	equ 1000h
   377                              <2> disasm_a32_memref:	equ 2000h
   378                              <2> disasm_a16_string:	equ 4000h
   379                              <2> disasm_a32_string:	equ 8000h
   380                              <2> disasm_hide_modrm:	equ 10000h
   381                              <2> disasm_asize_loop_nasm:	equ 20000h
   382                              <2> disasm_modrm_always:	equ 40000h
   383                              <2> DEFAULTASMOPTIONS equ disasm_lowercase|disasm_commablank|disasm_nasm 	| disasm_a16_memref | disasm_a32_memref 	| disasm_a16_string | disasm_a32_string
   386                              <2> 
   387                              <2> 	; serial_flags values
   388                              <2> sf_init_done:	equ 1
   389                              <2> sf_ctrl_c:	equ 2
   390                              <2> sf_double_ctrl_c:	equ 4
   391                              <2> sf_built_in_fifo:	equ 8
   392                              <2> sf_use_serial:		equ 10h
  1560                              <1> %endif
    20                                  %endif
    21                                  
    22                                  
    23                                  %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 E84216                  	call parseql		; process =addr
   261                                  
   262 00000052 F606[0200]01            	testopt [options], gg_do_not_skip_bp
   263 00000057 752A                    	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 7507                    	jne .cseip_take_eql
   268                                  
   269                                  	_386_PM_o32		; xor ecx, ecx
   270 00000065 31C9                    	xor cx, cx
   271 00000067 E8F907                  	call get_cseip_ecx_linear
   272 0000006A EB0B                    	jmp .got_cseip
   273                                  
   274                                  .cseip_take_eql:
   275 0000006C 8B1E[0400]              	mov bx, word [eqladdr + 4]
   276                                  	_386_PM_o32		; mov edx, dword [eqladdr]
   277 00000070 8B16[0000]              	mov dx, word [eqladdr]
   278 00000074 E8F607                  	call getlinear_d_b
   279                                  .got_cseip:
   280 00000077 7303E9(0000)            	jc error
   281 0000007C A3[0000]                	mov word [gg_first_cseip_linear], ax
   282 0000007F 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 00000083 4E                      	dec si
   300 00000084 E8(0000)                	call skipcomma
   301 00000087 4E                      	dec si
   302 00000088 BA[0000]                	mov dx, msg.again
   303 0000008B E8(0000)                	call isstring?
   304 0000008E 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 00000090 56                      	push si
   313 00000091 BE[0000]                	mov si, g_bplist.used_count
   314 00000094 31C0                    	xor ax, ax
   315 00000096 AC                      	lodsb			; ax = number of breakpoints set yet
   316 00000097 4E                      	dec si			; -> gg breakpoint list
   317 00000098 89C1                    	mov cx, ax
   318 0000009A 01C9                    	add cx, cx
   319 0000009C 01C9                    	add cx, cx		; * 4
   320                                  %if BPSIZE == 4
   321                                  %elif BPSIZE == 5
   322                                  	add cx, ax		; * 5
   323                                  %elif BPSIZE == 6
   324 0000009E 01C1                    	add cx, ax		; * 5
   325 000000A0 01C1                    	add cx, ax		; * 6
   326                                  %elif BPSIZE == 9
   327                                  	add cx, cx		; * 8
   328                                  	add cx, ax		; * 9
   329                                  %else
   330                                   %error Unexpected breakpoint size
   331                                  %endif
   332 000000A2 41                      	inc cx			; include the count
   333 000000A3 BF[0000]                	mov di, while_buffer	; es:di -> WHILE buffer
   334 000000A6 F3A4                    	rep movsb		; initialise WHILE buffer list
   335                                  
   336 000000A8 5E                      	pop si			; si -> separator after "AGAIN" keyword
   337 000000A9 BF[0100]                	mov di, while_buffer + 1	; -> first point
   338 000000AC 89C1                    	mov cx, ax
   339 000000AE B0CC                    	mov al, 0CCh
   340 000000B0 E306                    	jcxz .end
   341                                  .loop:
   342 000000B2 83C705                  	add di, BPSIZE - 1	; -> point content
   343 000000B5 AA                      	stosb			; initialise breakpoint content
   344 000000B6 E2FA                    	loop .loop
   345                                  .end:
   346                                  				; es:di -> after last breakpoint in array
   347 000000B8 E99000                  	jmp gg3			; parse additional points (do not dec si!)
   348                                  
   349                                  @@:
   350 000000BB F606[0000]20            	testopt [internalflags2], dif2_gg_again
   351 000000C0 75CE                    	jnz gg_again
   352                                  
   353                                  
   354                                  gg_list:
   355 000000C2 BA[0000]                	mov dx, msg.list
   356 000000C5 E8(0000)                	call isstring?
   357 000000C8 757B                    	jne .not
   358                                  
   359 000000CA AC                      	lodsb
   360 000000CB E8(0000)                	call chkeol
   361                                  
   362 000000CE 800E[0000]05            	setopt [internalflags2], dif2_gg_is_first | dif2_gg_skip_cseip
   363                                  
   364 000000D3 BE[0000]                	mov si, g_bplist.bp
   365 000000D6 31C9                    	xor cx, cx
   366 000000D8 8A4CFF                  	mov cl, byte [si - 1]
   367 000000DB 31DB                    	xor bx, bx
   368 000000DD E360                    	jcxz .none
   369                                  .loop:
   370 000000DF 43                      	inc bx
   371 000000E0 51                      	push cx
   372 000000E1 53                      	push bx
   373                                  
   374 000000E2 89D8                    	mov ax, bx		; 1-based index
   375 000000E4 BF[0000]                	mov di, line_out
   376 000000E7 E8E906                  	call ordinalbyte
   377                                  
   378 000000EA 57                      	push di
   379 000000EB 81EF[0300]              	sub di, line_out + 1 + 2
   380                                  				; 1 = a digit, 2 = ordinal suffix,
   381                                  				; result = how many additional digits are used
   382 000000EF BA[0000]                	mov dx, msg.list_bp.first
   383 000000F2 01FA                    	add dx, di
   384 000000F4 E8(0000)                	call putsz		; show blanks first
   385 000000F7 5F                      	pop di
   386 000000F8 E8(0000)                	call putsline
   387                                  
   388 000000FB E84704                  	call gg_bb_lods_bp_linear
   389                                  				; BPSIZE implied
   390                                  
   391 000000FE BF[0000]                	mov di, msg.list_bp.address1
   392 00000101 92                      	xchg ax, dx
   393 00000102 E8(0000)                	call hexword
   394 00000105 47                      	inc di
   395                                  	; mov di, msg.list_bp.address2
   396 00000106 92                      	xchg ax, dx
   397 00000107 E8(0000)                	call hexword
   398                                  
   399 0000010A E88C06                  	call gg_bb_check_is_first
   400                                  				; we set up the dif2_gg_skip_cseip flag,
   401 0000010D B9[0000]                	mov cx, msg.list_bp_not_cseip
   402                                  				;  so if CY (do not skip), initialise this
   403 00000110 7203                    	jc .not_cseip
   404                                  				;  if NC (do skip), use other string
   405                                  %if _PM
   406                                  	push bx
   407                                  	mov bx, word [reg_cs]
   408                                  	cmp byte [eqflag], 0
   409                                  	je @F
   410                                  	mov bx, word [eqladdr + 4]
   411                                  @@:
   412                                  	call test_d_b_bit
   413                                  	pop bx
   414                                  	mov cx, msg.list_bp_cseip_32
   415                                  	jnz @F			; if 32-bit cs -->
   416                                  %endif
   417 00000112 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 00000115 51                      	push cx
   429 00000116 BF[0000]                	mov di, line_out
   430 00000119 E8(0000)                	call bp_display_offset	; BPSIZE implied
   431 0000011C 57                      	push di
   432                                  %endif
   433 0000011D BF[0000]                	mov di, msg.list_bp.value
   434 00000120 AC                      	lodsb			; BPSIZE implied
   435 00000121 E8(0000)                	call hexbyte
   436                                  
   437 00000124 BA[0000]                	mov dx, msg.list_bp.second
   438 00000127 E8(0000)                	call putsz
   439                                  
   440                                  %if BPSIZE == 6 || BPSIZE == 9
   441 0000012A 5F                      	pop di
   442 0000012B E8(0000)                	call putsline
   443 0000012E 59                      	pop cx
   444                                  %endif
   445                                  
   446 0000012F BA[0000]                	mov dx, msg.list_bp.third
   447 00000132 E8(0000)                	call putsz
   448                                  
   449 00000135 89CA                    	mov dx, cx
   450 00000137 E8(0000)                	call putsz
   451                                  
   452 0000013A 5B                      	pop bx
   453 0000013B 59                      	pop cx
   454 0000013C E2A1                    	loop .loop
   455                                  .end:
   456                                  	; mov dx, msg.list_bp_first_detected
   457                                  	; testopt [internalflags2], dif2_gg_first_detected
   458                                  	; jnz .putsz
   459 0000013E C3                      	retn
   460                                  
   461                                  .none:
   462 0000013F BA[0000]                	mov dx, msg.list_bp_none
   463                                  .putsz:
   464 00000142 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 00000145 BF[0000]                	mov di, while_buffer	; es:di -> WHILE buffer
   482 00000148 31C0                    	xor ax, ax
   483 0000014A AA                      	stosb			; counter of saved breakpoints
   484                                  gg3:
   485                                  	; dec si		; don't use skipcomm0 instead - need to restore al
   486 0000014B E8(0000)                	call skipcomma
   487 0000014E E8(0000)                	call iseol?
   488 00000151 7442                    	je gg4			; if done -->
   489                                  
   490 00000153 4E                      	dec si
   491 00000154 BA[0000]                	mov dx, msg.remember
   492 00000157 E8(0000)                	call isstring?
   493 0000015A AC                      	lodsb
   494 0000015B 7510                    	jne @F
   495                                  
   496 0000015D E8(0000)                	call chkeol
   497 00000160 89F9                    	mov cx, di		; -> after last point
   498 00000162 BE[0000]                	mov si, while_buffer	; ds:si -> WHILE buffer
   499 00000165 29F1                    	sub cx, si		; = size of list
   500 00000167 BF[0000]                	mov di, g_bplist.used_count
   501                                  				; es:di -> gg breakpoint list
   502 0000016A F3A4                    	rep movsb		; copy list over
   503 0000016C C3                      	retn
   504                                  
   505                                  @@:
   506 0000016D 8B1E[0400]              	mov bx, word [eqladdr+4]; default segment
   507 00000171 E81C07                  	call getlinearaddr	; get linear address into bx:dx (CHG edx)
   508 00000174 7303E9(0000)            	jc error
   509 00000179 803E[0000]10            	cmp byte [while_buffer], _NUM_G_BP
   510 0000017E 7203E9(0000)            	jae error		; can't store another breakpoint, g_bplist is full -->
   511 00000183 92                      	xchg ax, dx		; ax = low word
   512 00000184 AB                      	stosw
   513 00000185 93                      	xchg ax, bx		; to store high byte/word
   514                                  %if _PM
   515                                  	stosw
   516                                  %else
   517 00000186 AA                      	stosb			; bits 24-31 (dh) always zero in 21-bit addresses
   518                                  %endif
   519                                  				; BPSIZE implied
   520                                  %if BPSIZE == 6
   521 00000187 A1[0000]                	mov ax, word [bp_offset]
   522 0000018A AB                      	stosw			; write offset (R86M-only 16-bit)
   523                                  %elif BPSIZE == 9
   524                                  	mov ax, word [bp_offset]
   525                                  	stosw
   526                                  	mov ax, word [bp_offset + 2]
   527                                  	stosw			; write offset (PM 32-bit)
   528                                  %endif
   529 0000018B B0CC                    	mov al, 0CCh
   530 0000018D AA                      	stosb			; later filled with the byte read from this address
   531 0000018E FE06[0000]              	inc byte [while_buffer]	; increment count
   532 00000192 4E                      	dec si
   533 00000193 EBB6                    	jmp short gg3
   534                                  
   535                                  gg4:
   536 00000195 89F9                    	mov cx, di		; -> after last point
   537 00000197 BE[0000]                	mov si, while_buffer	; ds:si -> WHILE buffer
   538 0000019A 29F1                    	sub cx, si		; = size of list
   539 0000019C BF[0000]                	mov di, g_bplist.used_count
   540                                  				; es:di -> gg breakpoint list
   541 0000019F F3A4                    	rep movsb		; copy list over
   542                                  
   543                                  %if _RH
   544 000001A1 E8(0000)                	call enable_rh
   545                                  %endif
   546                                  
   547 000001A4 F606[0000]08            	testopt [options3], opt3_gg_no_paging
   548 000001A9 7405                    	jz @F
   549 000001AB 8026[0000]F7            	clropt [internalflags], pagedcommand
   550                                  @@:
   551                                  
   552                                  gg5:
   553 000001B0 E8CB14                  	call tpg_initialise_empty_auxbuff
   554                                  %if _BREAKPOINTS
   555 000001B3 E81104                  	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 000001B6 BE[0000]                	mov si, g_bplist.used_count
   564 000001B9 31C0                    	xor ax, ax
   565 000001BB AC                      	lodsb			; si-> first point
   566 000001BC 89C1                    	mov cx, ax		; cx = number of saved breakpoints
   567 000001BE 51                      	push cx
   568 000001BF E87B05                  	call gg_writepoints	; Store breakpoint bytes in the given locations.
   569 000001C2 5A                      	pop dx
   570                                  		; dx = number of points tried to write
   571                                  		; cx = number of points not written
   572 000001C3 7342                    	jnc .points_set		; successful -->
   573                                  
   574                                  
   575                                  		; Failure to write to a gg breakpoint. Now the fun starts!
   576 000001C5 29CA                    	sub dx, cx		; = number of points written
   577 000001C7 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 000001C9 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   586                                  				; reserve space for bb error info
   587                                  %endif
   588 000001CC 89E5                    	mov bp, sp		; -> behind gg error info, -> bb error info
   589 000001CE 01D2                    	add dx, dx
   590 000001D0 29D4                    	sub sp, dx		; reserve space for gg error info
   591 000001D2 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 000001D3 E86F04                  	call gg_restorepoints_and_init_error_info
   595                                  %if _BREAKPOINTS
   596 000001D6 51                      	push cx
   597                                  		; Next, restore the bb points.
   598 000001D7 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   599                                  				; = index above last one to restore
   600 000001DA E8B804                  	call bb_restorepoints_and_init_error_info
   601 000001DD 59                      	pop cx			; (preserve index of failed gg point)
   602                                  %endif
   603 000001DE 58                      	pop ax
   604                                  
   605 000001DF E88F01                  	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 000001E2 89CE                    	mov si, cx
   612 000001E4 01F6                    	add si, si
   613 000001E6 01F6                    	add si, si		; *4
   614                                  %if BPSIZE == 4
   615                                  %elif BPSIZE == 5
   616                                  	add si, cx		; * 5
   617                                  %elif BPSIZE == 6
   618 000001E8 01CE                    	add si, cx		; * 5
   619 000001EA 01CE                    	add si, cx		; * 6
   620                                  %elif BPSIZE == 9
   621                                  	add si, si		; * 8
   622                                  	add si, cx		; * 9
   623                                  %else
   624                                   %error Unexpected breakpoint size
   625                                  %endif
   626 000001EC 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 000001F0 51                      	push cx
   632 000001F1 FF7402                  	 push word [si + 2]
   633 000001F4 FF34                    	 push word [si]		; stack: linear address
   634 000001F6 BB0080                  	mov bx, 8000h		; bh = 80h (gg),
   635                                  				;  bl = what we tried to restore (n/a)
   636 000001F9 E8900F                  	call display_breakpoint_failure
   637 000001FC 59                      	pop cx
   638 000001FD E82A06                  	call gg_handlefailedrestore
   639                                  %if _BREAKPOINTS
   640 00000200 E8F805                  	call bb_handlefailedrestore
   641 00000203 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 00000206 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 00000207 F606[0000]10            	testopt [internalflags2], dif2_gg_first_detected
   662 0000020C 7503E90A01              	jz .only_run		; easy case, no cseip point detected -->
   663                                  
   664                                  
   665                                  		; Enter special mode: Restore cseip breakpoint content.
   666 00000211 800E[0000]02            	setopt [internalflags2], dif2_gg_skip_non_cseip
   667                                  
   668 00000216 89D1                    	mov cx, dx		; = number of points set
   669                                  %if _BREAKPOINTS
   670 00000218 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   671                                  %endif
   672 0000021B 89E5                    	mov bp, sp		; -> behind error info
   673                                  %if _NUM_G_BP
   674 0000021D 89CA                    	mov dx, cx
   675 0000021F 01D2                    	add dx, dx
   676 00000221 29D4                    	sub sp, dx
   677 00000223 E81F04                  	call gg_restorepoints_and_init_error_info
   678                                  
   679 00000226 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 00000228 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
   686                                  
   687                                  		; Enter special mode: Skip cseip breakpoints.
   688 0000022D 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 00000232 E81304                  	call gg_restorepoints
   693                                  
   694                                  		; Exit special mode: No longer skip cseip breakpoints.
   695 00000235 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 0000023A 51                      	push cx
   700 0000023B B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   701 0000023E E85404                  	call bb_restorepoints_and_init_error_info
   702 00000241 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 00000242 E8E505                  	call gg_handlefailedrestore
   712                                  %endif
   713                                  %if _BREAKPOINTS
   714 00000245 E8B305                  	call bb_handlefailedrestore
   715                                  %endif
   716                                  %if _NUM_G_BP
   717                                   %if _BREAKPOINTS
   718 00000248 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 0000024B E9(0000)                	jmp cmd3
   726                                  
   727                                  .gg_restore_cseip_success:
   728                                  %if _BREAKPOINTS
   729 0000024E B91000                  	mov cx, (_NUM_B_BP + _NUM_SYM_BP)
   730                                  				; = index above last one to restore
   731 00000251 E84104                  	call bb_restorepoints_and_init_error_info
   732 00000254 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 00000256 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
   738                                  
   739                                  		; Enter special mode: Skip cseip breakpoints.
   740 0000025B 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 00000260 31C9                    	xor cx, cx
   746 00000262 8A0E[0000]              	mov cl, byte [g_bplist.used_count]
   747 00000266 E8DF03                  	call gg_restorepoints
   748 00000269 51                      	push cx
   749                                  %endif
   750 0000026A B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   751 0000026D E82804                  	call bb_restorepoints
   752                                  %if _NUM_G_BP
   753 00000270 59                      	pop cx
   754                                  %endif
   755                                  
   756                                  		; Exit special mode: No longer skip cseip breakpoints.
   757 00000271 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
   758                                  
   759 00000276 EBCA                    	jmp .gg_bb_cseip_fail_common
   760                                  
   761                                  @@:
   762                                  		; Success! Now discard the reserved error info.
   763 00000278 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                                  	call resetmode
   772                                  %endif
   773 0000027B E83614                  	call seteq		; make the = operand take effect
   774 0000027E BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
   775 00000281 8B1E[0000]              	mov bx, word [reg_cs]
   776                                  	_386_PM_o32	; mov esi, dword [reg_eip]
   777 00000285 8B36[0000]              	mov si, word [reg_eip]
   778                                  .pp2:
   779 00000289 E83E10                  	call pp16		; get next instruction byte into AL
   780 0000028C BF[0000]                	mov di, ppbytes
   781 0000028F B9[0000]                	mov cx, PPLEN_ONLY_STRING
   782                                  %if _SYMBOLIC
   783                                  	mov byte [pp_instruction], al
   784                                  %endif
   785 00000292 F2AE                    	repne scasb
   786 00000294 7522                    	jne .not_p		; if not one of these -->
   787                                  %if _LINK_COMPAT
   788 00000296 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 0000029A A880                    	test al, PP_PREFIX	; prefix ?
   793 0000029C 740E                    	jz .pp3			; no -->
   794 0000029E 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 000002A0 FECA                    	dec dl
   800 000002A2 75E5                    	jnz .pp2		; if not out of bytes -->
   801 000002A4 C706[0000][0000]        	mov word [gg_deferred_message], msg.warnprefix
   802 000002AA EB0C                    	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                                  _386_PM	call pp_fix32bitflags
   809 000002AC A847                    	test al, PP_VARSIZ | PP_SIZ_MASK
   810 000002AE 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                                  _386_PM	call test_d_b_bit
   830                                  _386_PM	jnz .32			; full 32-bit offset valid -->
   831                                  _386_PM	movzx esi, si		; clear high word here
   832                                  .32:
   833 000002B3 E87E0F                  	call proceedbreakpoint	; run until the breakpoint is hit
   834                                  		; This call might return modeswitched.
   835 000002B6 EB03                    	jmp short @F
   836                                  
   837                                  .not_p:
   838 000002B8 E84D0A                  	call traceone		; call common code
   839                                  @@:
   840 000002BB 9C                      	pushf
   841                                  
   842                                  		; Exit special mode, do not skip non-cseip breakpoints anymore.
   843 000002BC 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
   844                                  
   845                                  		; Enter special mode: Skip matching/restoring cseip breakpoint.
   846 000002C1 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
   847                                  
   848 000002C6 F6C47F                  	test ah, 7Fh		; error happened during proceedbreakpoint ?
   849 000002C9 743D                    	jz @F			; no -->
   850                                  
   851 000002CB 59                      	pop cx			; (discard flags on stack)
   852                                  
   853                                  %if _NUM_G_BP
   854 000002CC 31C9                    	xor cx, cx
   855 000002CE 8A0E[0000]              	mov cl, byte [g_bplist.used_count]
   856                                  %endif
   857                                  
   858                                  %if _BREAKPOINTS
   859 000002D2 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   860                                  				; reserve space for bb error info
   861                                  %endif
   862 000002D5 89E5                    	mov bp, sp		; -> behind gg error info, -> bb error info
   863                                  %if _NUM_G_BP
   864 000002D7 89CA                    	mov dx, cx
   865 000002D9 01D2                    	add dx, dx
   866 000002DB 29D4                    	sub sp, dx		; reserve space for gg error info
   867                                  %endif
   868 000002DD 50                      	push ax
   869                                  %if _NUM_G_BP
   870 000002DE E86403                  	call gg_restorepoints_and_init_error_info
   871                                  %endif
   872                                  %if _BREAKPOINTS
   873 000002E1 51                      	 push cx
   874 000002E2 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   875 000002E5 E8AD03                  	call bb_restorepoints_and_init_error_info
   876 000002E8 59                      	 pop cx
   877                                  %endif
   878                                  		; Exit special mode: No longer skip cseip breakpoints.
   879 000002E9 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
   880 000002EE 58                      	pop ax
   881 000002EF 51                      	 push cx
   882                                  
   883                                  %if _PM
   884                                  	call resetmode
   885                                  %endif
   886 000002F0 E87E00                  	call put_deferred_message_silent
   887                                  
   888 000002F3 FF36[0200]              	 push word [tpg_proceed_bp + 2]
   889 000002F7 FF36[0000]              	 push word [tpg_proceed_bp]
   890 000002FB 8A1E[0500]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
   891 000002FF B700                    	mov bh, 0		; proceed breakpoint
   892 00000301 E8880E                  	call display_breakpoint_failure
   893 00000304 59                      	 pop cx
   894 00000305 E93AFF                  	jmp .gg_bb_cseip_fail_common
   895                                  
   896                                  
   897                                  @@:
   898 00000308 9D                      	popf			; CF
   899                                  
   900 00000309 7218                    	jc .after_run		; an unexpected interrupt occured -->
   901                                  
   902 0000030B E83A00                  	call .after_run_restore	; restore stuff
   903 0000030E E83B02                  	call gg_bb_check_hit	; expected interrupt matches our gg or bb ?
   904 00000311 731E                    	jnc .expectedinterrupt	; yes, handle expected interrupt -->
   905                                  
   906                                  
   907                                  		; Clear all special modes. Stop specialcasing cseip breakpoint.
   908 00000313 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
   911 00000318 E995FE                  	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 0000031B 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
   919                                  
   920 00000320 E83710                  	call run		; Now run the program.
   921                                  .after_run:
   922                                  %if _NUM_G_BP || _BREAKPOINTS
   923 00000323 E82200                  	call .after_run_restore
   924                                  
   925 00000326 E82302                  	call gg_bb_check_hit
   926                                  .after_gg_bb_check_hit:
   927 00000329 7306                    	jnc .expectedinterrupt
   928                                  %endif	; _NUM_G_BP || _BREAKPOINTS
   929                                  .unexpectedinterrupt:
   930                                  %if _PM
   931                                  	call resetmode
   932                                  %endif
   933 0000032B E84300                  	call put_deferred_message_silent
   934 0000032E E99B09                  	jmp unexpectedinterrupt	; print messages for unexpected breakpoint and quit.
   935                                  
   936                                  %if _NUM_G_BP || _BREAKPOINTS
   937                                  .expectedinterrupt:
   938 00000331 E85F00                  	call adjust_cseip_after_breakpoint
   939                                  				; it's one of our breakpoints, adjust (e)ip
   940                                  
   941 00000334 89C1                    	mov cx, ax		; handle_bb_* expects flags in cx
   942 00000336 50                      	push ax
   943 00000337 50                      	push ax			; handle_bb_* expects dword counter on stack
   944 00000338 E8A207                  	call handle_bb_hit_pass_match
   945 0000033B 58                      	pop ax
   946 0000033C 58                      	pop ax			; discard
   947 0000033D 7203E96EFE              	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                                  	call resetmode
   958                                  %endif
   959 00000342 E82C00                  	call put_deferred_message_silent
   960                                  				; (put bb message after gg_bb_check_hit call)
   961 00000345 E92E0D                  	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 00000348 83EC20                   	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
   969                                  				; reserve space for bb error info
   970 0000034B 89E5                    	mov bp, sp		; -> behind gg error info, -> bb error info
   971                                   %if _NUM_G_BP
   972 0000034D 31C9                    	xor cx, cx
   973 0000034F 8A0E[0000]              	mov cl, byte [g_bplist.used_count]
   974 00000353 89CA                    	mov dx, cx
   975 00000355 01D2                    	add dx, dx
   976 00000357 29D4                    	sub sp, dx		; reserve space for gg error info
   977 00000359 E8E902                  	call gg_restorepoints_and_init_error_info
   978                                  				; try restoring gg points, and fill error info
   979                                   %endif
   980                                   %if _BREAKPOINTS
   981 0000035C 51                      	push cx
   982 0000035D B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
   983                                  				; = index above last one to restore
   984 00000360 E83203                  	call bb_restorepoints_and_init_error_info
   985                                  				; try restoring bb points, and fill error info
   986 00000363 59                      	pop cx
   987                                   %endif
   988                                  
   989                                  %if _PM
   990                                  	call resetmode
   991                                  %endif
   992 00000364 E80A00                  	call put_deferred_message_silent
   993                                  
   994                                   %if _NUM_G_BP
   995 00000367 E8C004                  	call gg_handlefailedrestore
   996                                  				; handle gg point restore failures
   997                                   %endif
   998                                   %if _BREAKPOINTS
   999 0000036A E88E04                  	call bb_handlefailedrestore
  1000                                  				; handle bb point restore failures
  1001                                   %endif
  1002                                   %if _NUM_G_BP
  1003                                    %if _BREAKPOINTS
  1004 0000036D 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 00000370 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 00000371 BA[0000]                	mov dx, msg.empty_message
  1027 00000374 8716[0000]              	xchg dx, word [gg_deferred_message]
  1028 00000378 E8DA08                  	call putsz_silent
  1029 0000037B BA[750C]                	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 0000037E 57                      	push di
  1036 0000037F 31FF                    	xor di, di
  1037 00000381 873E[0000]              	xchg di, word [bb_deferred_message_in_lineout_behind]
  1038 00000385 85FF                    	test di, di
  1039 00000387 7408                    	jz @F
  1040 00000389 50                      	push ax
  1041 0000038A 53                      	push bx
  1042 0000038B 51                      	push cx
  1043 0000038C FFD2                    	call dx
  1044 0000038E 59                      	pop cx
  1045 0000038F 5B                      	pop bx
  1046 00000390 58                      	pop ax
  1047                                  @@:
  1048 00000391 5F                      	pop di
  1049 00000392 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 00000393 F606[0100]06            	testopt [internalflags2], 		dif2_tpg_adjusted_cseip | dif2_tpg_do_not_adjust
  1068 00000398 7509                    	jnz .retn
  1069 0000039A 800E[0100]02            	setopt [internalflags2], dif2_tpg_adjusted_cseip
  1070                                  _386_PM	mov bx, word [reg_cs]
  1071                                  _386_PM	call resetmode_and_test_d_b_bit
  1072                                  _386_PM	jz .16			; 16-bit cs -->
  1073                                  _386_PM	o32			; dec dword [reg_eip]
  1074                                  .16:
  1075 0000039F FF0E[0000]              	dec word [reg_eip]	; re-execute (restored) opcode one byte in front of this
  1076                                  .retn:
  1077 000003A3 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 000003A4 5589E5                  	lenter
  1109 000003A7 31C0                    	xor ax, ax
  1110                                  	lequ 1,		flag_trigger
  1111                                  	lequ 2,		flag_pass
  1112                                  	lequ 4,		flag_match
  1113                                  	lvar word,	flags
  1114 000003A9 50                      	 push ax
  1115                                  
  1116                                  		; Finish up. Check if it was one of _our_ breakpoints.
  1117 000003AA 813E[0000][0000]        	cmp word [run_int], int3msg
  1118 000003B0 7505                    	jne @F			; if not interrupt 03h -->
  1119                                  
  1120                                  			; Get previous cs:eip (where breakpoint was executed if any at all).
  1121 000003B2 E82A05                  	call get_cseip_of_possible_breakpoint
  1122                                  				; dx:ax = linear address of previous cs:eip
  1123                                  				; bx = reg_cs
  1124 000003B5 EB15                    	jmp .check
  1125                                  
  1126                                  @@:
  1127                                  		; For T/TP/P: if trace interrupt fired just while
  1128                                  		;  pointing at a bb point, do match.
  1129 000003B7 813E[0000][0000]        	cmp word [run_int], int1msg
  1130 000003BD 7403E95101              	jne .gg9
  1131                                  
  1132 000003C2 800E[0100]04            	setopt [internalflags2], dif2_tpg_do_not_adjust
  1133                                  				; remember that we should not adjust
  1134                                  	_386_PM_o32
  1135 000003C7 31C9                    	xor cx, cx
  1136 000003C9 E89704                  	call get_cseip_ecx_linear
  1137                                  				; get linear of this cs:(e)ip
  1138                                  .check:
  1139 000003CC 7303E94201              	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 000003D1 A3[0000]                	mov word [gg_next_cseip_linear], ax
  1144 000003D4 8916[0200]              	mov word [gg_next_cseip_linear + 2], dx
  1145                                  
  1146 000003D8 87DA                    	xchg bx, dx
  1147 000003DA 91                      	xchg cx, ax		; bx:cx = linear address of previous cs:eip
  1148 000003DB 31C0                    	xor ax, ax
  1149                                  .loop:
  1150 000003DD 53                      	push bx
  1151 000003DE 50                      	push ax
  1152 000003DF E8(0000)                	call calcpointbit	; bx = index, ah = value
  1153 000003E2 84A7[0000]              	test byte [b_bplist.used_mask+bx], ah
  1154                                  				; (NC)
  1155 000003E6 7503E91601              	jz .next
  1156 000003EB 84A7[0000]              	test byte [b_bplist.disabled_mask+bx], ah
  1157                                  				; (NC)
  1158 000003EF 7403E90D01              	jnz .next
  1159 000003F4 58                      	pop ax
  1160 000003F5 5B                      	pop bx
  1161 000003F6 53                      	push bx
  1162 000003F7 50                      	push ax
  1163 000003F8 89C6                    	mov si, ax
  1164 000003FA 01F6                    	add si, si
  1165 000003FC 01F6                    	add si, si
  1166                                  %if BPSIZE == 4
  1167                                  %elif BPSIZE == 5
  1168                                  	add si, ax
  1169                                  %elif BPSIZE == 6
  1170 000003FE 01C6                    	add si, ax		; * 5
  1171 00000400 01C6                    	add si, ax		; * 6
  1172                                  %elif BPSIZE == 9
  1173                                  	add si, si		; * 8
  1174                                  	add si, ax		; * 9
  1175                                  %else
  1176                                   %error Unexpected breakpoint size
  1177                                  %endif
  1178 00000402 81C6[0000]              	add si, b_bplist.bp	; -> point
  1179                                  
  1180 00000406 E83C01                  	call gg_bb_lods_bp_linear
  1181                                  
  1182 00000409 E88D03                  	call gg_bb_check_is_first
  1183 0000040C 7203E9F000              	jnc .next
  1184                                  
  1185 00000411 39C8                    	cmp ax, cx
  1186 00000413 7403E9E900              	jne .next
  1187 00000418 39DA                    	cmp dx, bx
  1188 0000041A 7403E9E200              	jne .next
  1189                                  
  1190                                  .hit:
  1191 0000041F 58                      	 pop ax
  1192 00000420 50                      	 push ax
  1193                                  
  1194 00000421 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 00000425 89C7                    	mov di, ax
  1209 00000427 01FF                    	add di, di
  1210                                  
  1211 00000429 8BB5[0000]              	mov si, [b_bplist.when + di]
  1212                                  				; si -> condition
  1213 0000042D 85F6                    	test si, si		; any ?
  1214 0000042F 741B                    	jz @F			; no -->
  1215                                  %if _PM
  1216                                  	call resetmode
  1217                                  %endif
  1218 00000431 FF36[0000]              	push word [rc]
  1219 00000435 8F06[0000]              	pop word [priorrc]
  1220 00000439 AC                      	lodsb
  1221 0000043A E8(0000)                	nearcall getexpression	; parse stored expression
  1222 0000043D E8(0000)                	call chkeol
  1223 00000440 E8(0000)                	nearcall toboolean	; get boolean
  1224 00000443 85D2                    	test dx, dx		; true ?
  1225 00000445 7503E9B700              	jz .next		; no, skip -->
  1226 0000044A 58                      	 pop ax
  1227 0000044B 50                      	 push ax
  1228                                  @@:
  1229                                  
  1230 0000044C 8D9D[0000]              	lea bx, [b_bplist.counter + di]
  1231                                  				; word [bx] = this matched point's counter
  1232                                  
  1233 00000450 F646FE03                	test byte [bp + ?flags], ?flag_trigger | ?flag_pass
  1234 00000454 7413                    	jz @F			; none set yet ? -->
  1235 00000456 E8C100                  	call step_pass_counter	; step counter even if already matched
  1236 00000459 7203E9A300              	jnc .next		; (either is already set, so additional
  1237                                  				;  setting of ?flag_pass is skipped)
  1238 0000045E F646FE01                	test byte [bp + ?flags], ?flag_trigger
  1239 00000462 7403E99A00              	jnz .next		; (trigger is already set, so skip triggering)
  1240 00000467 EB05                    	jmp .setup_trigger	; triggered (after previous pass match)
  1241                                  
  1242                                  @@:
  1243 00000469 E8AE00                  	call step_pass_counter	; step counter of matched point, no flag yet
  1244 0000046C 7340                    	jnc .check_pass		; not triggered, check for pass match -->
  1245                                  
  1246                                  .setup_trigger:
  1247                                  		; Trigger! (And the first detected triggering point.)
  1248 0000046E 804EFE01                	or byte [bp + ?flags], ?flag_trigger
  1249                                  
  1250 00000472 51                      	push cx
  1251 00000473 BF[0000]                	mov di, line_out
  1252 00000476 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 00000479 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 0000047C 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 0000047E E8(0000)                	call hexbyte		; store index of this point
  1277                                  
  1278                                  		; Get counter of this breakpoint.
  1279 00000481 8B07                    	mov ax, word [bx]
  1280                                  
  1281                                  		; Is it equal to default ?
  1282 00000483 3D0080                  	cmp ax, 8000h
  1283 00000486 7409                    	je @F			; yes, skip -->
  1284                                  
  1285 00000488 BE[0000]                	mov si, msg.bb_hit.2.counter
  1286 0000048B E8AF00                  	call copy_single_counted_string
  1287                                  		; Now si -> msg.bb_hit.3.counter.no_id
  1288                                  
  1289                                  		; Store counter in message.
  1290 0000048E E8(0000)                	call hexword
  1291                                  
  1292                                  @@:
  1293 00000491 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  1294 00000496 7407                    	jz @F
  1295 00000498 F606[0200]08            	testopt [options], gg_bb_hit_no_repeat
  1296 0000049D EB05                    	jmp @FF
  1297                                  @@:
  1298 0000049F F606[0200]10            	testopt [options], tp_bb_hit_no_repeat
  1299                                  @@:
  1300 000004A4 7406                    	jz @F
  1301 000004A6 C706[0000][0000]        	mov word [lastcmd], dmycmd
  1302                                  @@:
  1303 000004AC EB1D                    	jmp .trigger_common
  1304                                  
  1305                                  
  1306                                  .check_pass:
  1307 000004AE 7451                    	jz .next		; no pass match ? -->
  1308                                  
  1309 000004B0 804EFE02                	or byte [bp + ?flags], ?flag_pass
  1310                                  
  1311 000004B4 51                      	push cx
  1312 000004B5 BF[0000]                	mov di, line_out
  1313 000004B8 BE[0000]                	mov si, msg.bb_pass.1
  1314 000004BB E87F00                  	call copy_single_counted_string
  1315                                  		; Now si -> msg.bb_pass.2
  1316                                  
  1317 000004BE 89C2                    	mov dx, ax
  1318                                  		; Store breakpoint index in message.
  1319 000004C0 E8(0000)                	call hexbyte		; store index of this point
  1320                                  
  1321 000004C3 E87700                  	call copy_single_counted_string
  1322                                  		; Now si -> msg.bb_pass.3.no_id
  1323                                  
  1324                                  		; Get counter of this breakpoint.
  1325 000004C6 8B07                    	mov ax, word [bx]
  1326                                  		; Store counter in message.
  1327 000004C8 E8(0000)                	call hexword
  1328                                  
  1329                                  .trigger_common:
  1330 000004CB 53                      	push bx
  1331                                  %if _SYMBOLIC
  1332                                  	cmp dx, _NUM_B_BP	; symbol breakpoint ?
  1333                                  	jae @F			; yes, no ID -->
  1334                                  %endif
  1335 000004CC BBFFFF                  	mov bx, -1
  1336 000004CF E8(0000)                	call get_set_id_offset_length
  1337 000004D2 F6C7FC                  	test bh, 63 << 2	; length nonzero ?
  1338 000004D5 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 000004D7 BE[0000]                	mov si, msg.bb_hitpass_id.short
  1344 000004DA 80FF74                  	cmp bh, 29 << 2		; long ?
  1345 000004DD 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 000004DF BE[0000]                	mov si, msg.bb_hitpass_id.long
  1350                                  .trigger_short_id:
  1351                                  
  1352 000004E2 E85800                  	call copy_single_counted_string
  1353 000004E5 88F9                    	mov cl, bh
  1354 000004E7 D0E9                    	shr cl, 1
  1355 000004E9 D0E9                    	shr cl, 1		; cx = length
  1356 000004EB 81E3FF03                	and bx, 1023		; bx = offset
  1357 000004EF 8DB7[0000]              	lea si, [b_bplist.idbuffer + bx]
  1358 000004F3 F3A4                    	rep movsb
  1359                                  
  1360 000004F5 BE[0000]                	mov si, msg.bb_hitpass_id.after
  1361                                  
  1362                                  @@:
  1363 000004F8 5B                      	pop bx
  1364 000004F9 E84100                  	call copy_single_counted_string
  1365                                  
  1366 000004FC 893E[0000]              	mov word [bb_deferred_message_in_lineout_behind], di
  1367 00000500 59                      	pop cx
  1368                                  
  1369                                  .next:
  1370 00000501 58                      	pop ax
  1371 00000502 5B                      	pop bx
  1372                                  
  1373 00000503 40                      	inc ax
  1374 00000504 83F810                  	cmp ax, _NUM_B_BP + _NUM_SYM_BP
  1375 00000507 7303E9D1FE              	jb .loop
  1376                                  
  1377 0000050C 8B46FE                  	mov ax, word [bp + ?flags]
  1378 0000050F A807                    	test al, ?flag_pass | ?flag_trigger | ?flag_match
  1379 00000511 7503                    	jnz .return		; (NC)
  1380                                  
  1381                                  .gg9:
  1382 00000513 31C0                    	xor ax, ax
  1383 00000515 F9                      	stc
  1384                                  .return:
  1385 00000516 89EC5D                  	lleave
  1386 00000519 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 0000051A F707FF3F                	test word [bx], 3FFFh		; is it already at a terminal state ?
  1396 0000051E 740A                    	jz .no_decrement		; yes, do not further decrement -->
  1397 00000520 FF0F                    	dec word [bx]			; decrement (to 0/4000h/8000h/C000h)
  1398 00000522 7417                    	jz .trigger			; case for decrementing 1 to 0 -->
  1399 00000524 813F0040                	cmp word [bx], 4000h
  1400 00000528 7411                    	je .trigger			; case for decrementing 4001h to 4000h
  1401                                  .no_decrement:
  1402 0000052A 813F0080                	cmp word [bx], 8000h		; decrement resulted in 8000h
  1403 0000052E 740B                    	je .trigger			;  or was already in that state? -->
  1404 00000530 813F00C0                	cmp word [bx], 0_C000h
  1405 00000534 7405                    	je .trigger			; or C000h -->
  1406                                  .proceed:
  1407 00000536 F6470140                	test byte [bx + 1], 40h		; (NC) ZR if no pass message
  1408 0000053A C3                      	retn
  1409                                  
  1410                                  .trigger:
  1411 0000053B F9                      	stc
  1412 0000053C 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 0000053D 91                      	xchg ax, cx
  1428 0000053E 31C0                    	xor ax, ax
  1429 00000540 AC                      	lodsb
  1430 00000541 91                      	xchg ax, cx
  1431 00000542 F3A4                    	rep movsb
  1432 00000544 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 00000545 AD                      	lodsw
  1442 00000546 92                      	xchg ax, dx
  1443                                  %if _PM
  1444                                  	lodsw
  1445                                  %else
  1446 00000547 31C0                    	xor ax, ax
  1447 00000549 AC                      	lodsb
  1448                                  %endif
  1449 0000054A 92                      	xchg ax, dx
  1450 0000054B 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 0000054C E855FE                  	call bb_check_hit
  1476 0000054F 720D                    	jc .gg_check_hit
  1477                                  
  1478 00000551 A801                    	test al, 1		; actual bb hit ?
  1479 00000553 7507                    	jnz .ret_NC		; yes, return as hit
  1480                                  
  1481 00000555 50                      	push ax			; bb is pass match or any other match,
  1482 00000556 E80500                  	call gg_check_hit	;  is gg a match ?
  1483 00000559 58                      	pop ax
  1484 0000055A 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 0000055C F8                      	clc
  1491 0000055D 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 0000055E 813E[0000][0000]        	cmp word [run_int], int3msg
  1515 00000564 752D                    	jne .gg9		; if not interrupt 03h -->
  1516                                  
  1517                                  			; Get previous cs:eip (where breakpoint was executed if any at all).
  1518 00000566 E87603                  	call get_cseip_of_possible_breakpoint
  1519                                  				; dx:ax = linear address of previous cs:eip
  1520 00000569 7228                    	jc .gg9
  1521 0000056B BE[0000]                	mov si, g_bplist.bp
  1522 0000056E 31C9                    	xor cx, cx
  1523 00000570 8A4CFF                  	mov cl, byte [si-1]	; number of saved breakpoints
  1524 00000573 E31E                    	jcxz .gg9		; none, so always unexpected -->
  1525                                  
  1526 00000575 89C7                    	mov di, ax
  1527 00000577 89D3                    	mov bx, dx		; bx:di = linear address of previous cs:(e)ip
  1528                                  
  1529                                  .loop_gg6:
  1530 00000579 E8C9FF                  	call gg_bb_lods_bp_linear
  1531                                  
  1532 0000057C E81A02                  	call gg_bb_check_is_first
  1533 0000057F 730D                    	jnc .next
  1534                                  
  1535 00000581 39DA                    	cmp dx, bx
  1536 00000583 7509                    	jne .next
  1537 00000585 39F8                    	cmp ax, di
  1538 00000587 7505                    	jne .next
  1539                                  
  1540                                  .hit:
  1541 00000589 B80700                  	mov ax, 7
  1542 0000058C F8                      	clc
  1543 0000058D 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 0000058E 83C603                  	add si, 3		; skip word offset and byte content
  1551                                  %elif BPSIZE == 9
  1552                                  	add si, 5		; skip dword offset and byte content
  1553                                  %endif
  1554                                  				; BPSIZE implied
  1555 00000591 E2E6                    	loop .loop_gg6		; try next if there's any
  1556                                  
  1557                                  .gg9:
  1558 00000593 31C0                    	xor ax, ax
  1559 00000595 F9                      	stc
  1560 00000596 C3                      	retn
  1561                                  %endif
  1562                                  
  1563                                  
  1564                                  %if _DELAY_BEFORE_BP
  1565                                  delay_before_bp:
  1566 00000597 F606[0300]04            	testopt [options3], opt3_delay_before_bp
  1567 0000059C 7428                    	jz .ret
  1568 0000059E F606[0200]80            	testopt [internalflags3], dif3_delayed
  1569 000005A3 7521                    	jnz .ret
  1570 000005A5 800E[0200]80            	setopt [internalflags3], dif3_delayed
  1571 000005AA 06                      	push es
  1572 000005AB 57                      	push di
  1573 000005AC 50                      	push ax
  1574 000005AD BF4000                  	mov di, 40h		; dual mode segment/selector
  1575 000005B0 8EC7                    	mov es, di
  1576 000005B2 268B3E6C00              	mov di, word [es:6Ch]
  1577                                  @@:
  1578 000005B7 263B3E6C00              	cmp di, word [es:6Ch]
  1579 000005BC 7505                    	jne @F
  1580 000005BE E8(0000)                	call idle
  1581 000005C1 EBF4                    	jmp @B
  1582                                  @@:
  1583 000005C3 58                      	pop ax
  1584 000005C4 5F                      	pop di
  1585 000005C5 07                      	pop es
  1586                                  .ret:
  1587 000005C6 C3                      	retn
  1588                                  %endif
  1589                                  
  1590                                  
  1591                                  %if _BREAKPOINTS
  1592                                  bb_writepoints_init_reset:
  1593 000005C7 BF[0000]                	mov di, b_bplist.bp
  1594 000005CA B0CC                    	mov al, 0CCh
  1595 000005CC B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  1596                                  .loop:
  1597 000005CF 83C705                  	add di, BPSIZE - 1
  1598 000005D2 AA                      	stosb
  1599 000005D3 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 000005D5 E8D500                  	call bb_writepoints
  1707 000005D8 735B                    	jnc .retn
  1708                                  
  1709 000005DA 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1710                                  				; reserve space for bb error info
  1711 000005DD 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 000005DF 50                      	push ax
  1716 000005E0 51                      	push cx
  1717 000005E1 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 000005E4 E83A0B                  	call proceed_writepoint_restore
  1724                                  		; This call might return modeswitched.
  1725 000005E7 BB0000                  	mov bx, 0		; (preserve CF)
  1726 000005EA 7305                    	jnc @F
  1727 000005EC 80CC80                  	or ah, 80h		; mark error during restoration
  1728 000005EF 89C3                    	mov bx, ax		; bx & 80h set: error restoring pp
  1729                                  @@:
  1730                                  
  1731 000005F1 59                      	pop cx
  1732 000005F2 58                      	pop ax			; error info + index of failed point
  1733                                  
  1734 000005F3 89CE                    	mov si, cx
  1735 000005F5 01F6                    	add si, si
  1736 000005F7 01F6                    	add si, si		; * 4
  1737                                  %if BPSIZE == 4
  1738                                  %elif BPSIZE == 5
  1739                                  	add si, cx		; * 5
  1740                                  %elif BPSIZE == 6
  1741 000005F9 01CE                    	add si, cx		; * 5
  1742 000005FB 01CE                    	add si, cx		; * 6
  1743                                  %elif BPSIZE == 9
  1744                                  	add si, si		; * 8
  1745                                  	add si, cx		; * 9
  1746                                  %else
  1747                                   %error Unexpected breakpoint size
  1748                                  %endif
  1749 000005FD 81C6[0000]              	add si, b_bplist.bp	; -> point
  1750                                  
  1751 00000601 53                      	push bx
  1752                                  
  1753 00000602 E86CFD                  	call put_deferred_message_silent
  1754                                  				; CHG: dx
  1755                                  
  1756 00000605 83F9FF                  	cmp cx, -1
  1757 00000608 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 0000060A FF7402                  	 push word [si + 2]
  1763 0000060D FF34                    	 push word [si]		; stack: linear address
  1764 0000060F BB0040                  	mov bx, 4000h		; bh = 40h (bb),
  1765                                  				;  bl = what we tried to restore (n/a)
  1766 00000612 E8770B                  	call display_breakpoint_failure
  1767                                  		; This function calls resetmode.
  1768                                  
  1769                                  @@:
  1770 00000615 E8E301                  	call bb_handlefailedrestore
  1771                                  		; This function calls resetmode.
  1772                                  
  1773 00000618 58                      	pop ax
  1774 00000619 F6C480                  	test ah, 80h		; pp failed to restore ?
  1775 0000061C 7411                    	jz @F
  1776                                  
  1777 0000061E FF36[0200]              	 push word [tpg_proceed_bp + 2]
  1778 00000622 FF36[0000]              	 push word [tpg_proceed_bp]
  1779 00000626 8A1E[0500]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
  1780 0000062A B700                    	mov bh, 0		; proceed breakpoint
  1781 0000062C E85D0B                  	call display_breakpoint_failure
  1782                                  @@:
  1783 0000062F 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  1784                                  				; discard bb error info
  1785 00000632 E9(0000)                	jmp cmd3
  1786                                  
  1787                                  .retn:
  1788 00000635 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 00000636 16                      	push ss
  1800 00000637 07                      	pop es
  1801 00000638 89EF                    	mov di, bp		; es:di -> behind error info
  1802 0000063A 51                      	push cx
  1803 0000063B 4F                      	dec di
  1804 0000063C 4F                      	dec di
  1805 0000063D 31C0                    	xor ax, ax
  1806 0000063F FD                      	std			; _AMD_ERRATUM_109_WORKAROUND does not apply
  1807 00000640 F3AB                    	rep stosw		; initialize error info
  1808 00000642 FC                      	cld
  1809 00000643 59                      	pop cx
  1810 00000644 C3                      	retn
  1811                                  
  1812                                  
  1813                                  gg_restorepoints_and_init_error_info:
  1814 00000645 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 00000648 89CE                    	mov si, cx
  1838 0000064A 01F6                    	add si, si
  1839 0000064C 01F6                    	add si, si		; * 4
  1840                                  %if BPSIZE == 4
  1841                                  %elif BPSIZE == 5
  1842                                  	add si, cx		; * 5
  1843                                  %elif BPSIZE == 6
  1844 0000064E 01CE                    	add si, cx		; * 5
  1845 00000650 01CE                    	add si, cx		; * 6
  1846                                  %elif BPSIZE == 9
  1847                                  	add si, si		; * 8
  1848                                  	add si, cx		; * 9
  1849                                  %else
  1850                                   %error Unexpected breakpoint size
  1851                                  %endif
  1852 00000652 81C6[FAFF]              	add si, g_bplist.bp - BPSIZE	; -> last point in list (first to restore)
  1853                                  
  1854 00000656 F8                      	clc			; assume success
  1855 00000657 51                      	push cx
  1856 00000658 9C                      	pushf
  1857 00000659 E329                    	jcxz .done		; nothing to do -->
  1858                                  .loop:
  1859 0000065B E8E300                  	call gg_writepoints_restore	; Restore breakpoint bytes.
  1860 0000065E 7324                    	jnc .done		; successful -->
  1861 00000660 5A                      	pop dx			; discard flags
  1862 00000661 5B                      	pop bx
  1863 00000662 53                      	push bx
  1864 00000663 9C                      	pushf			; store (CY) flags
  1865                                  
  1866 00000664 50                      	push ax
  1867 00000665 89F7                    	mov di, si
  1868 00000667 81EF[0600]              	sub di, BPSIZE+g_bplist.bp
  1869                                  %if BPSIZE == 5 || BPSIZE == 6 || BPSIZE == 9
  1870 0000066B 89F8                    	mov ax, di
  1871 0000066D 31D2                    	xor dx, dx
  1872 0000066F BF0600                  	mov di, BPSIZE
  1873 00000672 F7F7                    	div di
  1874 00000674 89C7                    	mov di, ax		; di = 0-based point index
  1875 00000676 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 00000678 29DF                    	sub di, bx
  1882 0000067A 29DF                    	sub di, bx
  1883 0000067C 8F03                    	pop word [bp+di]	; store error info
  1884 0000067E 49                      	dec cx			; exclude the failed point
  1885 0000067F 83EE0C                  	sub si, 2*BPSIZE	; -> the point _before_ failed one
  1886 00000682 EBD7                    	jmp short .loop
  1887                                  .done:
  1888 00000684 9D                      	popf			; get flags. CY if any couldn't be restored
  1889 00000685 59                      	pop cx			; restore cx
  1890 00000686 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 00000687 16                      	push ss
  1905 00000688 07                      	pop es
  1906 00000689 89EF                    	mov di, bp
  1907 0000068B 31C0                    	xor ax, ax
  1908 0000068D 51                      	push cx
  1909 0000068E B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  1910 00000691 F3AB                    	rep stosw
  1911 00000693 59                      	pop cx
  1912 00000694 C3                      	retn
  1913                                  
  1914                                  
  1915                                  bb_restorepoints_and_init_error_info:
  1916 00000695 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 00000698 F8                      	clc			; assume success
  1940 00000699 9C                      	pushf
  1941 0000069A E30F                    	jcxz .done
  1942                                  .loop:
  1943 0000069C E81400                  	call bb_writepoints_restore
  1944 0000069F 730A                    	jnc .done
  1945 000006A1 5A                      	pop dx			; (discard flags)
  1946 000006A2 9C                      	pushf			; store (CY) flags
  1947                                  				; cx = index of point that failed to write
  1948                                  				; ah = reason, al = new byte value (reason 3)
  1949 000006A3 89CF                    	mov di, cx
  1950 000006A5 01FF                    	add di, di
  1951 000006A7 8903                    	mov word [bp + di], ax	; store error info
  1952 000006A9 EBF1                    	jmp .loop
  1953                                  
  1954                                  .done:
  1955 000006AB 9D                      	popf			; CF
  1956 000006AC 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 000006AD 31C9                    	xor cx, cx
  1973 000006AF BF0100                  	mov di, 1
  1974 000006B2 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 000006B3 31FF                    	xor di, di		; (NC)
  1993                                  bb_wp:
  1994                                  	lframe near
  1995 000006B5 5589E5                  	lenter
  1996                                  	lvar	word, is_write
  1997 000006B8 57                      	 push di
  1998                                  
  1999 000006B9 F646FE01                	test byte [bp + ?is_write], 1
  2000                                  				; (NC) is it writing ?
  2001 000006BD 7458                    	jz .next		; no, is restoring, first decrement cx -->
  2002                                  
  2003                                  .loop:
  2004 000006BF 89C8                    	mov ax, cx
  2005 000006C1 E8(0000)                	call calcpointbit	; bx = index, ah = value
  2006 000006C4 84A7[0000]              	test byte [b_bplist.used_mask+bx], ah
  2007                                  				; (NC)
  2008 000006C8 744D                    	jz .next
  2009 000006CA 84A7[0000]              	test byte [b_bplist.disabled_mask+bx], ah
  2010                                  				; (NC)
  2011 000006CE 7547                    	jnz .next
  2012                                  
  2013 000006D0 89CE                    	mov si, cx
  2014 000006D2 01F6                    	add si, si
  2015 000006D4 01F6                    	add si, si		; * 4
  2016                                  %if BPSIZE == 4
  2017                                  %elif BPSIZE == 5
  2018                                  	add si, cx		; * 5
  2019                                  %elif BPSIZE == 6
  2020 000006D6 01CE                    	add si, cx		; * 5
  2021 000006D8 01CE                    	add si, cx		; * 6
  2022                                  %elif BPSIZE == 9
  2023                                  	add si, si		; * 8
  2024                                  	add si, cx		; * 9
  2025                                  %else
  2026                                   %error Unexpected breakpoint size
  2027                                  %endif
  2028 000006DA 81C6[0000]              	add si, b_bplist.bp	; -> point
  2029                                  
  2030 000006DE E864FE                  	call gg_bb_lods_bp_linear
  2031                                  				; dx:ax = linear address
  2032                                  
  2033 000006E1 E8B500                  	call gg_bb_check_is_first
  2034 000006E4 7331                    	jnc .next		; (NC)
  2035                                  
  2036 000006E6 E81602                  	call getsegmented	; bx:(e)dx = segmented address
  2037                                  %if BPSIZE == 6
  2038 000006E9 AD                      	lodsw			; skip word offset
  2039                                  %elif BPSIZE == 9
  2040                                  	lodsw
  2041                                  	lodsw			; skip dword offset
  2042                                  %endif
  2043 000006EA AC                      	lodsb			; get byte to write
  2044 000006EB B402                    	mov ah, 2
  2045 000006ED 723E                    	jc .return		; not in PM anymore/address not available --> (CY)
  2046 000006EF F646FE01                	test byte [bp + ?is_write], 1
  2047                                  				; writing?
  2048 000006F3 7517                    	jnz .forward_nocheck	; yes -->
  2049                                  
  2050                                  .backward_check:
  2051 000006F5 50                      	push ax
  2052 000006F6 E8(0000)                	call readmem		; read current byte
  2053 000006F9 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  2054 000006FB B483                    	mov ah, 83h		; (80h = error occurred while restoring)
  2055 000006FD F9                      	stc
  2056 000006FE 752D                    	jne .return_discard	; nope --> (CY)
  2057 00000700 58                      	pop ax
  2058 00000701 E8(0000)                	call writemem		; return the byte to its original value
  2059 00000704 7211                    	jc .next		; failed --> (CY, handled there)
  2060 00000706 C644FFCC                	mov byte [si-1], 0CCh	; reset stored point
  2061 0000070A EB0B                    	jmp short .next
  2062                                  
  2063                                  .forward_nocheck:
  2064                                  %if _DELAY_BEFORE_BP
  2065 0000070C E888FE                  	call delay_before_bp
  2066                                  %endif
  2067 0000070F E8(0000)                	call writemem
  2068 00000712 7203                    	jc .next
  2069 00000714 8844FF                  	mov byte [si-1], al	; save the previous byte there
  2070                                  .next:
  2071 00000717 B401                    	mov ah, 1		; (in case of error)
  2072 00000719 7212                    	jc .return		; failed to write --> (CY)
  2073                                  
  2074 0000071B F646FE01                	test byte [bp + ?is_write], 1
  2075 0000071F 7505                    	jnz .is_write_next
  2076 00000721 49                      	dec cx			; restore: decrement index
  2077 00000722 799B                    	jns .loop		; decremented to 0FFFFh ?  no, loop -->
  2078 00000724 EB06                    	jmp .return_NC
  2079                                  
  2080                                  .is_write_next:
  2081 00000726 41                      	inc cx			; write: increment index
  2082 00000727 83F910                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  2083                                  				; above last ?
  2084 0000072A 7293                    	jb .loop		; no, loop -->
  2085                                  .return_NC:
  2086 0000072C F8                      	clc
  2087                                  .return:
  2088                                  .return_discard:
  2089 0000072D 730A                    	jnc .ret
  2090                                  
  2091 0000072F F646FE01                	test byte [bp + ?is_write], 1
  2092                                  				; restoring ?
  2093 00000733 7503                    	jnz .ret_CY		; no -->
  2094 00000735 80CC80                  	or ah, 80h		; error occurred while restoring
  2095                                  .ret_CY:
  2096 00000738 F9                      	stc
  2097                                  .ret:
  2098 00000739 89EC5D                  	lleave
  2099 0000073C 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 0000073D BF0100                  	mov di, 1
  2117 00000740 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 00000741 31FF                    	xor di, di		; (NC)
  2131                                  gg_wp:
  2132 00000743 E347                    	jcxz .return		;if nothing to do --> (still NC from xor/test)
  2133                                  .loop:
  2134 00000745 E8FDFD                  	call gg_bb_lods_bp_linear
  2135                                  				; dx:ax = linear address
  2136                                  
  2137 00000748 E84E00                  	call gg_bb_check_is_first
  2138 0000074B 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 0000074D 83C603                  	add si, 3		; skip word offset and byte content
  2145                                  %elif BPSIZE == 9
  2146                                  	add si, 5		; skip dword offset and byte content
  2147                                  %endif
  2148                                  				; BPSIZE implied
  2149                                  
  2150 00000750 85FF                    	test di, di		; (NC)
  2151 00000752 7532                    	jnz .next		; going forward -->
  2152 00000754 EB22                    	jmp .next_lea_si	; (NC)
  2153                                  
  2154                                  		; Handle this breakpoint.
  2155                                  @@:
  2156 00000756 E8A601                  	call getsegmented	; bx:(e)dx = segmented address
  2157                                  %if BPSIZE == 6
  2158 00000759 AD                      	lodsw			; skip word offset
  2159                                  %elif BPSIZE == 9
  2160                                  	lodsw
  2161                                  	lodsw			; skip dword offset
  2162                                  %endif
  2163 0000075A AC                      	lodsb			; get byte to write
  2164 0000075B B402                    	mov ah, 2
  2165 0000075D 722D                    	jc .return		; not in PM anymore/address not available --> (CY)
  2166 0000075F 85FF                    	test di, di		; writing?
  2167 00000761 751A                    	jnz .forward_nocheck	; yes -->
  2168                                  
  2169                                  .backward_check:
  2170 00000763 50                      	push ax
  2171 00000764 E8(0000)                	call readmem		; read current byte
  2172 00000767 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  2173 00000769 B483                    	mov ah, 83h		; (80h = error occurred while restoring)
  2174 0000076B F9                      	stc
  2175 0000076C 7529                    	jne .return_discard	; nope --> (CY)
  2176 0000076E 58                      	pop ax
  2177 0000076F E8(0000)                	call writemem		; return the byte to its original value
  2178 00000772 7212                    	jc .next		; failed --> (CY, handled there)
  2179 00000774 C644FFCC                	mov byte [si-1], 0CCh	; reset stored point
  2180                                  .next_lea_si:
  2181 00000778 8D74F4                  	lea si, [si-2*BPSIZE]	; adjust (for reverse writing)
  2182 0000077B EB09                    	jmp short .next
  2183                                  
  2184                                  .forward_nocheck:
  2185                                  %if _DELAY_BEFORE_BP
  2186 0000077D E817FE                  	call delay_before_bp
  2187                                  %endif
  2188 00000780 E8(0000)                	call writemem
  2189 00000783 8844FF                  	mov byte [si-1], al	; save the previous byte there
  2190                                  .next:
  2191 00000786 B401                    	mov ah, 1		; (in case of error)
  2192 00000788 7202                    	jc .return		; failed to write --> (CY)
  2193 0000078A E2B9                    	loop .loop
  2194                                  .return:			; (NC)
  2195 0000078C 730A                    	jnc .ret
  2196                                  
  2197 0000078E 85FF                    	test di, di		; restoring ?
  2198 00000790 7503                    	jnz .ret_CY		; no -->
  2199 00000792 80CC80                  	or ah, 80h		; error occurred while restoring
  2200                                  .ret_CY:
  2201 00000795 F9                      	stc
  2202 00000796 52                      	push dx			; (counteract effect of pop)
  2203                                  .return_discard:
  2204 00000797 5A                      	pop dx
  2205                                  .ret:
  2206 00000798 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 00000799 F606[0000]07            	testopt [internalflags2], 		dif2_gg_is_first | dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  2227 0000079E 7418                    	jz .continue
  2228                                  
  2229 000007A0 3906[0000]              	cmp [gg_first_cseip_linear], ax
  2230 000007A4 7514                    	jne .is_not_first
  2231 000007A6 3916[0200]              	cmp [gg_first_cseip_linear + 2], dx
  2232 000007AA 750E                    	jne .is_not_first
  2233                                  
  2234                                  .is_first:
  2235 000007AC 800E[0000]10            	setopt [internalflags2], dif2_gg_first_detected
  2236 000007B1 F606[0000]04            	testopt [internalflags2], dif2_gg_skip_cseip
  2237 000007B6 7509                    	jnz .skip
  2238                                  .continue:
  2239 000007B8 F9                      	stc
  2240 000007B9 C3                      	retn
  2241                                  
  2242                                  .is_not_first:
  2243 000007BA F606[0000]02            	testopt [internalflags2], dif2_gg_skip_non_cseip
  2244 000007BF 74F7                    	jz .continue
  2245                                  .skip:
  2246 000007C1 F8                      	clc
  2247 000007C2 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 000007C3 53                      	push bx
  2255 000007C4 51                      	push cx
  2256 000007C5 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 000007C6 BF[0000]                	mov di, line_out
  2263 000007C9 E80700                  	call ordinalbyte
  2264 000007CC E8(0000)                	call putsline
  2265 000007CF 5A                      	pop dx
  2266 000007D0 59                      	pop cx
  2267 000007D1 5B                      	pop bx
  2268 000007D2 C3                      	retn
  2269                                  
  2270                                  
  2271                                  ordinalbyte:
  2272 000007D3 E8(0000)                	call decbyte
  2273 000007D6 8B45FE                  	mov ax, [di - 2]	; al = lower address, higher decimal digit
  2274                                  				; ah = higher address, lower decimal digit
  2275 000007D9 3C31                    	cmp al, '1'
  2276 000007DB 7417                    	je .gotsuf_th		; 11th, 12th, 13th or other teen -->
  2277 000007DD BA7374                  	mov dx, "st"
  2278 000007E0 80FC31                  	cmp ah, '1'
  2279 000007E3 7412                    	je .gotsuf		; if low digit was one -->
  2280 000007E5 BA6E64                  	mov dx, "nd"
  2281 000007E8 80FC32                  	cmp ah, '2'
  2282 000007EB 740A                    	je .gotsuf		; if low digit was two -->
  2283 000007ED B272                    	mov dl, 'r'
  2284 000007EF 80FC33                  	cmp ah, '3'
  2285 000007F2 7403                    	je .gotsuf		; if low digit was three -->
  2286                                  .gotsuf_th:
  2287 000007F4 BA7468                  	mov dx, "th"
  2288                                  .gotsuf:
  2289 000007F7 89D0                    	mov ax, dx
  2290 000007F9 AB                      	stosw
  2291 000007FA 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                                  	call resetmode
  2307                                  %endif
  2308 000007FB 31FF                    	xor di, di
  2309 000007FD 31C9                    	xor cx, cx
  2310 000007FF 16                      	push ss
  2311 00000800 07                      	pop es
  2312 00000801 BE[0000]                	mov si, b_bplist.bp
  2313                                  .loop:
  2314 00000804 8B03                    	mov ax, word [bp + di]
  2315 00000806 F6C47F                  	test ah, 7Fh		; failed ?
  2316 00000809 7414                    	jz .next
  2317 0000080B 51                      	push cx
  2318 0000080C 57                      	push di
  2319                                  				; cx = 0-based index
  2320 0000080D FF7402                  	 push word [si + 2]
  2321 00000810 FF34                    	 push word [si]		; stack: linear address
  2322 00000812 8A5C05                  	mov bl, byte [si + BPSIZE - 1]
  2323                                  				; bl = what we tried to restore
  2324 00000815 B740                    	mov bh, 40h		; bh = 40h (bb)
  2325 00000817 80CC80                  	or ah, 80h		; ah & 80h = set (is restore)
  2326 0000081A E86F09                  	call display_breakpoint_failure
  2327 0000081D 5F                      	pop di
  2328 0000081E 59                      	pop cx
  2329                                  .next:
  2330 0000081F 83C606                  	add si, BPSIZE
  2331 00000822 AF                      	scasw			; di += 2
  2332 00000823 41                      	inc cx
  2333 00000824 83F910                  	cmp cx, _NUM_B_BP + _NUM_SYM_BP
  2334 00000827 72DB                    	jb .loop
  2335                                  .end:
  2336 00000829 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                                  	call resetmode
  2352                                  %endif
  2353 0000082A 89CF                    	mov di, cx
  2354 0000082C 01FF                    	add di, di
  2355 0000082E F7DF                    	neg di
  2356 00000830 16                      	push ss
  2357 00000831 07                      	pop es
  2358 00000832 BB0000                  	mov bx, 0
  2359 00000835 BE[0000]                	mov si, g_bplist.bp
  2360 00000838 E325                    	jcxz .end
  2361                                  .loop:
  2362 0000083A 8B03                    	mov ax, word [bp+di]
  2363 0000083C F6C47F                  	test ah, 7Fh		; failed?
  2364 0000083F 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 00000841 53                      	push bx
  2371 00000842 57                      	push di
  2372 00000843 89D9                    	mov cx, bx		; cx = 0-based index
  2373 00000845 FF7402                  	 push word [si + 2]
  2374 00000848 FF34                    	 push word [si]		; stack: linear address
  2375 0000084A 8A5C05                  	mov bl, byte [si + BPSIZE - 1]
  2376                                  				; bl = what we tried to restore
  2377 0000084D B780                    	mov bh, 80h		; bh = 80h (gg)
  2378 0000084F 80CC80                  	or ah, 80h		; ah & 80h = set (is restore)
  2379 00000852 E83709                  	call display_breakpoint_failure
  2380 00000855 5F                      	pop di
  2381 00000856 5B                      	pop bx
  2382                                  .next:
  2383 00000857 43                      	inc bx			; increment counter
  2384 00000858 83C606                  	add si, BPSIZE		; -> next point
  2385 0000085B 47                      	inc di
  2386 0000085C 47                      	inc di			; di+bp-> next error info
  2387 0000085D 75DB                    	jnz .loop		; not yet at end -->
  2388                                  .end:
  2389 0000085F 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                                  	_386_PM_o32		; or ecx, byte -1
  2402 00000860 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 00000863 8B1E[0000]              	mov bx, [reg_cs]	; bx = cs
  2414                                  	_386_PM_o32
  2415 00000867 8B16[0000]              	mov dx, [reg_eip]	; (e)dx = (e)ip
  2416                                  	_386_PM_o32
  2417 0000086B 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                                  	push di
  2440                                  	mov di, test_d_b_bit
  2441                                  	call getlinear_common
  2442                                  	pop di
  2443                                  	retn
  2444                                  
  2445                                  getlinear_high_limit: section_of_function
  2446                                  	push di
  2447                                  	mov di, test_high_limit
  2448                                  	call getlinear_common
  2449                                  	pop di
  2450                                  	retn
  2451                                  
  2452                                  getlinear_32bit: section_of_function
  2453                                  	push di
  2454                                  	mov di, .always_NZ
  2455                                  	call getlinear_common
  2456                                  	pop di
  2457                                  	retn
  2458                                  
  2459                                  .always_NZ:
  2460                                  	test di, di
  2461                                  	retn
  2462                                  
  2463                                  section_of getlinear_16bit
  2464                                  getlinear_16bit: section_of_function
  2465                                  	push di
  2466                                  	mov di, .always_ZR
  2467                                  	call getlinear_common
  2468                                  	pop di
  2469                                  	retn
  2470                                  
  2471                                  .always_ZR:
  2472                                  	cmp di, di
  2473                                  	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                                  	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 0000086D 53                      	 push bx
  2526                                  %if _PM
  2527                                  	call ispm
  2528                                  	jnz .rm
  2529                                  	mov ax, 0006h
  2530                                  	 push cx
  2531                                  	push dx
  2532                                  	int 31h			; get selector base address into cx:dx
  2533                                  	pop ax			; (edxh:)ax = offset, cx:dx = base
  2534                                  	jc .return_cx_bx
  2535                                  
  2536                                  _386	call di
  2537                                  _386	jz .16
  2538                                  _386	push edx
  2539                                  _386	pop bx
  2540                                  _386	pop bx			; bx = high word edx (in 32-bit PM segment)
  2541                                  _386	jmp .32
  2542                                  .16:				; bx:ax = offset
  2543                                  	xor bx, bx		; 16-bit PM segment, clear offset high word
  2544                                  .32:
  2545                                  	add ax, dx
  2546                                  	adc bx, cx		; add the base
  2547                                  	xchg bx, dx		; dx:ax = 32-bit linear address
  2548                                  	clc
  2549                                  
  2550                                  .return_cx_bx:
  2551                                  	 pop cx
  2552                                  	 pop bx
  2553                                  	retn
  2554                                  .rm:
  2555                                  %endif
  2556 0000086E 89D8                    	mov ax, bx
  2557 00000870 51                      	push cx
  2558 00000871 B104                    	mov cl, 4
  2559 00000873 D3C0                    	rol ax, cl
  2560 00000875 59                      	pop cx
  2561 00000876 BBF0FF                  	mov bx, 0FFF0h
  2562 00000879 21C3                    	and bx, ax		; bx = low word adjustment
  2563 0000087B 83E00F                  	and ax, byte 0Fh	; ax = higher bits which don't fit in the low word
  2564 0000087E 01DA                    	add dx, bx
  2565 00000880 83D000                  	adc ax, byte 0
  2566 00000883 92                      	xchg ax, dx		; dx:ax = 21-bit linear address
  2567 00000884 F606[0100]10            	testopt [internalflags], debuggeeA20
  2568 00000889 7503                    	jnz .return_bx		; A20 line enabled, no need to adjust (NC)
  2569 0000088B 80E2EF                  	and dl, ~10h		; clear corresponding bit of the address if it was set (NC)
  2570                                  .return_bx:
  2571 0000088E 5B                      	 pop bx
  2572 0000088F 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                                  	call resetmode
  2589                                  %endif
  2590                                  %if !_LOADER
  2591                                  	_386_PM_o32	; or dword
  2592 00000890 830E[0000]FF            	or word [bp_offset], strict byte -1
  2593                                  %endif
  2594 00000895 E8(0000)                	call skipcomm0
  2595 00000898 3C40                    	cmp al, '@'
  2596 0000089A 7531                    	jne .at_not
  2597 0000089C AC                      	lodsb			; insure we have a blank or opening parens
  2598 0000089D 3C28                    	cmp al, '('
  2599 0000089F 740A                    	je .at
  2600 000008A1 3C09                    	cmp al, 9
  2601 000008A3 7406                    	je .at
  2602 000008A5 3C20                    	cmp al, 32
  2603 000008A7 7402                    	je .at
  2604 000008A9 EB1F                    	jmp .at_not_reload	; assume the @ is part of a symbol
  2605                                  
  2606                                  .at:
  2607 000008AB E8(0000)                	call skipwh0
  2608 000008AE 3C28                    	cmp al, '('
  2609 000008B0 750E                    	jne .at_not_paren
  2610                                  
  2611 000008B2 AC                      	lodsb
  2612 000008B3 E8(0000)                	nearcall getdword
  2613 000008B6 E8(0000)                	call skipwh0
  2614 000008B9 3C29                    	cmp al, ')'
  2615 000008BB 7520                    	jne .error
  2616 000008BD AC                      	lodsb
  2617                                  
  2618 000008BE EB03                    	jmp .at_got
  2619                                  
  2620                                  .at_not_paren:
  2621 000008C0 E8(0000)                	nearcall getdword
  2622                                  .at_got:
  2623                                  %ifn _PM
  2624                                  	; test bh, bh
  2625                                  	; jnz .error
  2626 000008C3 83FB11                  	cmp bx, 11h
  2627 000008C6 7315                    	jae .error
  2628                                  %endif
  2629 000008C8 F8                      	clc
  2630 000008C9 C3                      	retn
  2631                                  
  2632                                  .at_not_reload:
  2633 000008CA 4E                      	dec si
  2634 000008CB 4E                      	dec si
  2635 000008CC AC                      	lodsb
  2636                                  .at_not:
  2637 000008CD E8(0000)                	nearcall getaddrX
  2638                                  %if _PM
  2639                                  _no386	and word [bp_offset + 2], 0
  2640                                  %endif
  2641                                  %if !_LOADER
  2642                                  	_386_PM_o32		; mov dword [bp_offset], edx
  2643 000008D0 8916[0000]              	mov word [bp_offset], dx
  2644                                  %endif
  2645 000008D4 50                      	push ax
  2646 000008D5 E895FF                  	call getlinear_high_limit
  2647 000008D8 93                      	xchg bx, ax	; dx:bx = linear
  2648 000008D9 87D3                    	xchg dx, bx	; bx:dx = linear
  2649 000008DB 58                      	pop ax		; al = next character
  2650 000008DC C3                      	retn
  2651                                  
  2652                                  .error:
  2653 000008DD F9                      	stc
  2654 000008DE 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 000008DF A1[0000]                	mov ax, [tpg_possible_breakpoint]
  2669 000008E2 8B16[0200]              	mov dx, [tpg_possible_breakpoint + 2]
  2670                                  			; dx:ax = stored possible breakpoint address
  2671 000008E6 F606[0100]01            	testopt [internalflags2], dif2_tpg_have_bp
  2672 000008EB 7511                    	jnz .retn	; (NC) if already stored -->
  2673 000008ED E870FF                  	call get_cseip_minus_1_linear
  2674                                  			; dx:ax = linear address at cs:(e)ip - 1
  2675 000008F0 720C                    	jc .retn	; (CY) if getlinear failed -->
  2676 000008F2 A3[0000]                	mov [tpg_possible_breakpoint], ax
  2677 000008F5 8916[0200]              	mov [tpg_possible_breakpoint + 2], dx
  2678                                  			; store for later use
  2679 000008F9 800E[0100]01            	setopt [internalflags2], dif2_tpg_have_bp
  2680                                  			; (NC)
  2681                                  .retn:
  2682 000008FE 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                                  _386	xor ebx, ebx		; clear ebxh
  2709                                  	mov bx, sp
  2710                                  _386	xor edi, edi		; clear edih
  2711                                  	mov di, .back_after_switch
  2712                                  	call ispm
  2713                                  	jz .pm
  2714                                  .r86m:
  2715                                  d4	call d4message
  2716                                  d4	asciz "In switchmode.r86m",13,10
  2717                                  	mov ax, [dssel]		; switch rm -> pm
  2718                                  	mov si, [code_sel]
  2719                                  	mov dx, ax
  2720                                  	mov cx, ax
  2721                                  	jmp far [dpmi_rm2pm]
  2722                                  .pm:
  2723                                  d4	call d4message
  2724                                  d4	asciz "In switchmode.pm",13,10
  2725                                  	mov ax, [pspdbg]	; switch pm -> rm
  2726                                  	mov si, [code_seg]
  2727                                  	mov dx, ax
  2728                                  	mov cx, ax
  2729                                  	_386_o32	; jmp far dword [dpmi_pm2rm]
  2730                                  	jmp far [dpmi_pm2rm]
  2731                                  
  2732                                  .back_after_switch:
  2733                                  	xor byte [pm_2_86m_0], 2
  2734                                  	xoropt [internalflags], protectedmode
  2735                                  d4	call d4message
  2736                                  d4	asciz "In switchmode.back_after_switch",13,10
  2737                                  	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                                  	testopt [internalflags], switchbuffer
  2746                                  	jz .return		; no need to call -->
  2747                                  	_386_o32	; xor edi, edi
  2748                                  	xor di, di
  2749                                  	call ispm
  2750                                  	jz .pm
  2751                                  .r86m:
  2752                                  d4	call d4message
  2753                                  d4	asciz "In sr_state.r86m",13,10
  2754                                  	mov es, word [auxbuff_segorsel + soaSegment]
  2755                                  	call far [dpmi_rmsav]
  2756                                  	jmp .return
  2757                                  
  2758                                  .pm:
  2759                                  d4	call d4message
  2760                                  d4	asciz "In sr_state.pm",13,10
  2761                                  	mov es, word [auxbuff_segorsel + soaSelector]
  2762                                  	_386_o32	; call far dword [dpmi_pmsav]
  2763                                  	call far [dpmi_pmsav]
  2764                                  .return:
  2765                                  	push ss
  2766                                  	pop es
  2767                                  	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                                  	pushf
  2780                                  	testopt [internalflags], modeswitched	; switched mode previously ?
  2781                                  	jz .return		; no -->
  2782                                  d4	call d4message
  2783                                  d4	asciz "In resetmode (actually resetting)",13,10
  2784                                  subcpu 286
  2785                                  	_386_o32
  2786                                  	pusha
  2787                                  	call switchmode 	; switch back to the mode we were entered in (RM)
  2788                                  	mov al, 1
  2789                                  	call sr_state		; restore state
  2790                                  	call handle_mode_changed		; ! called with flag set
  2791                                  	clropt [internalflags], modeswitched	; reset the flag
  2792                                  _386	push ss
  2793                                  _386	pop gs
  2794                                  _386	push ss
  2795                                  _386	pop fs
  2796                                  	_386_o32
  2797                                  	popa
  2798                                  subcpureset
  2799                                  .return:
  2800                                  	popf
  2801                                  	sti
  2802                                  	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                                  	call ispm
  2848                                  	jnz .rm
  2849                                  .pm:
  2850                                  	push cx
  2851                                  	mov bx, word [scratchsel]
  2852                                  	xchg ax, dx
  2853                                  	xchg ax, cx		; cx:dx = linear address
  2854                                  	mov ax, 0007h
  2855                                  	int 31h			; set base to the address
  2856                                  	pop cx
  2857                                  	jc .invalid
  2858                                   %if 1
  2859                                  	push cx
  2860                                  	mov ax, 0008h
  2861                                  	xor cx, cx
  2862                                  	xor dx, dx
  2863                                  	int 31h			; set limit to zero (access to one byte only)
  2864                                  	pop cx
  2865                                  	jc .invalid
  2866                                   %endif
  2867                                  	_386_o32	; xor edx, edx
  2868                                  	xor dx, dx		; bx:(e)dx = selector:offset (using scratchsel with the address as base)
  2869                                  	retn			; (NC)
  2870                                  %endif
  2871                                  .rm:
  2872 000008FF 83FA10                  	cmp dx, byte 10h	; check for address space
  2873 00000902 7219                    	jb .nothma		; below HMA, normal access -->
  2874 00000904 7402                    	je .checkhma		; possibly in HMA -->
  2875                                  .nonrmspace:			; above HMA
  2876                                  %if _PM
  2877                                  		; It's a PM address but we are in RM.
  2878                                  	testopt [internalflags], canswitchmode
  2879                                  	jz .invalid		; can't switch to PM -->
  2880                                  .switchmodes:
  2881                                  	_386_o32
  2882                                  	push si
  2883                                  	_386_o32
  2884                                  	push di
  2885                                  	_386_o32
  2886                                  	push cx
  2887                                  	_386_o32
  2888                                  	push bp
  2889                                  	push dx
  2890                                  	push ax
  2891                                  d4	call d4message
  2892                                  d4	asciz "In getsegmented.switchmodes (switching to access memory beyond 1088 KiB)",13,10
  2893                                  	call remember_mode
  2894                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  2895                                  	mov al, 0
  2896                                  	call sr_state		; save state
  2897                                  	call switchmode 	; switch to PM
  2898                                  	call handle_mode_changed		; ! called with flag set
  2899                                  	pop ax
  2900                                  	pop dx
  2901                                  	_386_o32
  2902                                  	pop bp
  2903                                  	_386_o32
  2904                                  	pop cx
  2905                                  	_386_o32
  2906                                  	pop di
  2907                                  	_386_o32
  2908                                  	pop si
  2909                                  	jmp .pm
  2910                                  
  2911                                  .invalid:			; the address is inaccessible
  2912                                  %endif
  2913 00000906 F9                      	stc
  2914 00000907 C3                      	retn
  2915                                  
  2916                                  .checkhma:
  2917 00000908 83F8F0                  	cmp ax, -10h		; valid offset for HMA ?
  2918 0000090B 73F9                    	jae .nonrmspace		; no, above HMA -->
  2919 0000090D F606[0100]20            	testopt [internalflags], debuggerA20	; A20 on, HMA accessible ?
  2920 00000912 74F2                    	jz .nonrmspace		; no, treat as above HMA (DEBUGX) -->
  2921 00000914 BBFFFF                  	mov bx, 0FFFFh		; the HMA must always be addressed by segment FFFFh
  2922 00000917 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 0000091A 92                      	xchg ax, dx		; bx:dx = segment:offset
  2925 0000091B EB11                    	jmp .zero_edxh
  2926                                  
  2927                                  .nothma:
  2928 0000091D 51                      	push cx
  2929 0000091E B104                    	mov cl, 4
  2930 00000920 D3CA                    	ror dx, cl		; dx (high 4 bits) = high 4 bits of segment
  2931 00000922 89C3                    	mov bx, ax
  2932 00000924 D3EB                    	shr bx, cl		; bx = low 12 bits of segment
  2933 00000926 09DA                    	or dx, bx		; dx = segment
  2934 00000928 83E00F                  	and ax, byte 0Fh	; ax = low 4 bits of linear, used as offset (NC)
  2935 0000092B 92                      	xchg ax, dx
  2936 0000092C 93                      	xchg ax, bx		; bx:dx = segment:offset
  2937 0000092D 59                      	pop cx
  2938                                  .zero_edxh:
  2939                                  _386_PM	movzx edx, dx
  2940 0000092E 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 0000092F 8A64FE                  	mov ah, byte [si - 2]
  2957 00000932 80E4DF                  	and ah, TOUPPER
  2958 00000935 80FC54                  	cmp ah, 'T'
  2959 00000938 7508                    	jne @F
  2960 0000093A 88C4                    	mov ah, al
  2961 0000093C 80E4DF                  	and ah, TOUPPER
  2962 0000093F 80FC4D                  	cmp ah, 'M'
  2963                                  @@:
  2964 00000942 7542                    	jne isnotmodeset
  2965 00000944 E8(0000)                	call skipcomma
  2966 00000947 E8(0000)                	call iseol?
  2967 0000094A 7416                    	je ismodeget
  2968 0000094C E8(0000)                	nearcall getexpression
  2969 0000094F E8(0000)                	call chkeol		; expect end of line here
  2970 00000952 09DA                    	or dx, bx
  2971 00000954 7507                    	jnz .set		; selected nonzero -->
  2972                                  .clear:				; selected zero
  2973 00000956 8026[0000]FD            	clropt [options], traceints
  2974 0000095B EB05                    	jmp short .get
  2975                                  .set:
  2976 0000095D 800E[0000]02            	setopt [options], traceints
  2977                                  .get:
  2978                                  ismodeget:
  2979 00000962 B030                    	mov al, '0'
  2980 00000964 BE[0000]                	mov si, tmode0
  2981 00000967 F606[0000]02            	testopt [options], traceints
  2982 0000096C 7404                    	jz .zero
  2983 0000096E 40                      	inc ax
  2984 0000096F BE[0000]                	mov si, tmode1
  2985                                  .zero:
  2986 00000972 A2[0000]                	mov byte [tmodev], al
  2987 00000975 BF[0000]                	mov di, line_out
  2988 00000978 56                      	push si
  2989 00000979 BE[0000]                	mov si, tmodes
  2990 0000097C E8(0000)                	call showstring
  2991 0000097F 5E                      	pop si
  2992 00000980 E8(0000)                	call showstring
  2993 00000983 E9(0000)                	jmp putsline_crlf
  2994                                  
  2995                                  isnotmodeset:
  2996                                  %if _TSR && (_APPLICATION || _DEVICE)
  2997 00000986 80FC53                  	cmp ah, 'S'
  2998 00000989 750D                    	jne @F
  2999 0000098B 50                      	push ax
  3000 0000098C 8A04                    	mov al, byte [si]
  3001 0000098E 24DF                    	and al, TOUPPER
  3002 00000990 3C52                    	cmp al, 'R'
  3003 00000992 58                      	pop ax
  3004 00000993 7503E92C02              	je tsr
  3005                                  @@:
  3006                                  %endif
  3007                                  
  3008                                  %if _RH
  3009 00000998 E8(0000)                	call enable_rh
  3010                                  %endif
  3011                                  
  3012                                  %if _TTEST
  3013 0000099B 50                      	push ax
  3014 0000099C 80FC54                  	cmp ah, 'T'
  3015 0000099F 7516                    	jne @F
  3016 000009A1 8B04                    	mov ax, word [si]
  3017 000009A3 25DFDF                  	and ax, TOUPPER_W
  3018 000009A6 3D4553                  	cmp ax, "ES"
  3019 000009A9 750C                    	jne @F
  3020 000009AB 8A4402                  	mov al, byte [si + 2]
  3021 000009AE 24DF                    	and al, TOUPPER
  3022 000009B0 3C54                    	cmp al, 'T'
  3023 000009B2 7503E9A700              	je ttestcmd
  3024                                  @@:
  3025 000009B7 58                      	pop ax
  3026                                  %endif
  3027                                  
  3028 000009B8 8026[0300]F7            	clropt [internalflags], tt_p
  3029 000009BD 80FC50                  	cmp ah, 'P'
  3030 000009C0 7506                    	jne @F
  3031 000009C2 AC                      	lodsb
  3032 000009C3 800E[0300]08            	setopt [internalflags], tt_p
  3033                                  @@:
  3034                                  tt0:
  3035                                  %if _RH
  3036 000009C8 E8(0000)                	call enable_rh
  3037                                  %endif
  3038 000009CB C706[0000][C809]        	mov word [lastcmd], tt0
  3039 000009D1 8026[0100]EF            	clropt [internalflags2], dif2_is_pp
  3040 000009D6 E8280B                  	call parse_pt		; process arguments
  3041                                  
  3042                                  		; Do it <BX:CX=count> times.
  3043                                  tt1:
  3044 000009D9 53                      	push bx
  3045 000009DA 51                      	push cx
  3046                                  
  3047 000009DB F606[0300]08            	testopt [internalflags], tt_p
  3048 000009E0 743A                    	jz .not_p
  3049                                  
  3050                                  %if _PM
  3051                                  	call resetmode
  3052                                  %endif
  3053 000009E2 BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
  3054 000009E5 8B1E[0000]              	mov bx, word [reg_cs]
  3055                                  	_386_PM_o32	; mov esi, dword [reg_eip]
  3056 000009E9 8B36[0000]              	mov si, word [reg_eip]
  3057                                  .pp2:
  3058 000009ED E8DA08                  	call pp16		; get next instruction byte into AL
  3059 000009F0 BF[0000]                	mov di, ppbytes
  3060 000009F3 B9[0000]                	mov cx, PPLEN_ONLY_STRING
  3061                                  %if _SYMBOLIC
  3062                                  	mov byte [pp_instruction], al
  3063                                  %endif
  3064 000009F6 F2AE                    	repne scasb
  3065 000009F8 7522                    	jne .not_p		; if not one of these -->
  3066                                  %if _LINK_COMPAT
  3067 000009FA 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 000009FE A880                    	test al, PP_PREFIX	; prefix ?
  3072 00000A00 740E                    	jz .pp3			; no -->
  3073 00000A02 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 00000A04 FECA                    	dec dl
  3079 00000A06 75E5                    	jnz .pp2		; if not out of bytes -->
  3080 00000A08 BA[0000]                	mov dx, msg.warnprefix
  3081 00000A0B E8(0000)                	call putsz
  3082 00000A0E EB0C                    	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                                  _386_PM	call pp_fix32bitflags
  3089 00000A10 A847                    	test al, PP_VARSIZ | PP_SIZ_MASK
  3090 00000A12 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                                  _386_PM	call resetmode_and_test_d_b_bit
  3110                                  _386_PM	jnz .32			; full 32-bit offset valid -->
  3111                                  _386_PM	movzx esi, si		; clear high word here
  3112                                  .32:
  3113 00000A17 E81A08                  	call proceedbreakpoint	; run until the breakpoint is hit
  3114                                  		; This call might return modeswitched.
  3115 00000A1A EB03                    	jmp short @F
  3116                                  
  3117                                  .not_p:
  3118 00000A1C E8E902                  	call traceone		; call common code
  3119                                  @@:
  3120 00000A1F 7303E9A802              	jc unexpectedinterrupt	; an unexpected interrupt occured -->
  3121                                  %if _BREAKPOINTS
  3122 00000A24 BA0000                  	mov dx, 0		; do not skip WHILE
  3123 00000A27 7413                    	jz @F			; (breakpoint after instruction was hit)
  3124                                  
  3125                                  		; bb breakpoint was hit. dumpregs, then return
  3126 00000A29 E8B100                  	call handle_bb_hit_pass_match
  3127 00000A2C 7204                    	jc .actual_hit		; actual match ? -->
  3128 00000A2E 7414                    	jz tt2.nodump		; non-silent mode ? -->
  3129 00000A30 EB0A                    	jmp tt2			; silent mode -->
  3130                                  
  3131                                  .actual_hit:
  3132                                  %if _PM
  3133                                  	call resetmode
  3134                                  %endif
  3135 00000A32 E83CF9                  	call put_deferred_message_silent
  3136 00000A35 E83E06                  	call dumpregs_extended_silent
  3137 00000A38 59                      	pop cx
  3138 00000A39 5B                      	pop bx			; (discard counter)
  3139 00000A3A EB1B                    	jmp @FF
  3140                                  @@:
  3141                                  %endif
  3142                                  tt2:
  3143 00000A3C 52                      	push dx
  3144                                  %if _PM
  3145                                  	call resetmode
  3146                                  %endif
  3147 00000A3D E831F9                  	call put_deferred_message_silent
  3148 00000A40 E83306                  	call dumpregs_extended_silent
  3149                                  				; dump registers
  3150 00000A43 5A                      	pop dx			; preserve skip WHILE flag
  3151                                  .nodump:
  3152                                  
  3153 00000A44 E84F00                  	call tt_handle_while
  3154 00000A47 59                      	pop cx
  3155 00000A48 5B                      	pop bx
  3156                                  
  3157 00000A49 83E901                  	sub cx, 1
  3158 00000A4C 83DB00                  	sbb bx, 0		; decrement loop counter
  3159                                  
  3160 00000A4F 85DB                    	test bx, bx
  3161 00000A51 7508                    	jnz tt1_jmp		; loop -->
  3162 00000A53 85C9                    	test cx, cx
  3163 00000A55 7504                    	jnz tt1_jmp		; loop -->
  3164                                  
  3165                                  @@:
  3166                                  %if _PM
  3167                                  	call resetmode
  3168                                  %endif
  3169 00000A57 E8(0000)                	call silence_dump
  3170                                  
  3171 00000A5A C3                      	retn
  3172                                  
  3173                                  tt1_jmp:
  3174 00000A5B E97BFF                  	jmp tt1
  3175                                  
  3176                                  
  3177                                  %if _TTEST
  3178                                  ttestcmd:
  3179 00000A5E 58                      	pop ax
  3180 00000A5F 46                      	inc si
  3181 00000A60 46                      	inc si
  3182 00000A61 46                      	inc si
  3183 00000A62 E8(0000)                	call skipwhite
  3184                                  
  3185                                  .tt0:
  3186 00000A65 C706[0000][650A]        	mov word [lastcmd], .tt0
  3187 00000A6B 8026[0100]EF            	clropt [internalflags2], dif2_is_pp
  3188 00000A70 E88E0A                  	call parse_pt		; process arguments
  3189                                  
  3190                                  		; Do it <BX:CX=count> times.
  3191                                  .tt1:
  3192 00000A73 53                      	push bx
  3193 00000A74 51                      	push cx
  3194                                  
  3195                                  .tt2:
  3196                                  %if _PM
  3197                                  	call resetmode
  3198                                  %endif
  3199 00000A75 E8F9F8                  	call put_deferred_message_silent
  3200 00000A78 E8FB05                  	call dumpregs_extended_silent
  3201                                  				; dump registers
  3202                                  .nodump:
  3203                                  
  3204 00000A7B 31D2                    	xor dx, dx
  3205 00000A7D E81600                  	call tt_handle_while
  3206 00000A80 59                      	pop cx
  3207 00000A81 5B                      	pop bx
  3208                                  
  3209 00000A82 83E901                  	sub cx, 1
  3210 00000A85 83DB00                  	sbb bx, 0		; decrement loop counter
  3211                                  
  3212 00000A88 85DB                    	test bx, bx
  3213 00000A8A 7508                    	jnz .tt1_jmp		; loop -->
  3214 00000A8C 85C9                    	test cx, cx
  3215 00000A8E 7504                    	jnz .tt1_jmp		; loop -->
  3216                                  
  3217                                  @@:
  3218                                  %if _PM
  3219                                  	call resetmode
  3220                                  %endif
  3221 00000A90 E8(0000)                	call silence_dump
  3222                                  
  3223 00000A93 C3                      	retn
  3224                                  
  3225                                  .tt1_jmp:
  3226 00000A94 EBDD                    	jmp .tt1
  3227                                  %endif
  3228                                  
  3229                                  
  3230                                  		; INP:	dx = nonzero if to bypass while condition
  3231                                  tt_handle_while:
  3232 00000A96 85D2                    	test dx, dx
  3233 00000A98 7538                    	jnz @F
  3234 00000A9A F606[0300]04            	testopt [internalflags], tt_while
  3235 00000A9F 7431                    	jz @F
  3236                                  
  3237                                  %if _PM
  3238                                  	call resetmode
  3239                                  %endif
  3240 00000AA1 E82F00                  	call .point_to_condition
  3241                                  				; dx = si -> line_out with condition
  3242 00000AA4 FF36[0000]              	push word [rc]
  3243 00000AA8 8F06[0000]              	pop word [priorrc]
  3244 00000AAC AC                      	lodsb
  3245 00000AAD E8(0000)                	nearcall getexpression	; parse stored expression
  3246 00000AB0 E8(0000)                	call chkeol
  3247 00000AB3 E8(0000)                	nearcall toboolean	; get boolean
  3248 00000AB6 85D2                    	test dx, dx		; true ?
  3249 00000AB8 7518                    	jnz @F			; yes, continue -->
  3250                                  
  3251 00000ABA E8(0000)                	call silence_dump
  3252                                  
  3253 00000ABD BA[0000]                	mov dx, msg.while_terminated_before
  3254 00000AC0 E8(0000)                	call putsz
  3255 00000AC3 E80D00                  	call .point_to_condition
  3256 00000AC6 E8(0000)                	call putsz		; display condition
  3257 00000AC9 BA[0000]                	mov dx, msg.while_terminated_after
  3258 00000ACC E8(0000)                	call putsz
  3259 00000ACF E9(0000)                	jmp cmd3
  3260                                  
  3261                                  @@:
  3262 00000AD2 C3                      	retn
  3263                                  
  3264                                  
  3265                                  .point_to_condition:
  3266 00000AD3 16                      	push ss
  3267 00000AD4 07                      	pop es
  3268 00000AD5 16                      	push ss
  3269 00000AD6 1F                      	pop ds
  3270 00000AD7 BE[0000]                	mov si, while_buffer
  3271 00000ADA 89F2                    	mov dx, si
  3272 00000ADC 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 00000ADD 91                      	xchg ax, cx
  3302                                  
  3303 00000ADE F606[0100]08            	testopt [internalflags2], dif2_bp_failure
  3304 00000AE3 7569                    	jnz .actual_hit		; after failure, handle as actual hit
  3305                                  
  3306 00000AE5 A801                    	test al, 1		; actual hit ?  else: non-hit, pass or non-pass
  3307 00000AE7 7565                    	jnz .actual_hit		; yes -->
  3308                                  
  3309 00000AE9 A802                    	test al, 2		; at least pass match ?
  3310 00000AEB 7415                    	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                                  	call resetmode
  3319                                  %endif
  3320                                  	; call put_deferred_message_loud
  3321 00000AED BA[0000]                	mov dx, msg.empty_message
  3322 00000AF0 8716[0000]              	xchg dx, word [gg_deferred_message]
  3323 00000AF4 E8(0000)                	call putsz
  3324 00000AF7 BA[0000]                	mov dx, putsline
  3325 00000AFA E881F8                  	call put_bb_deferred_message_calling_dx
  3326                                  
  3327 00000AFD 50                      	push ax
  3328                                  	; call dumpregs_extended_loud
  3329                                  				; (includes handle_serial_flags_ctrl_c)
  3330 00000AFE E8(0000)                	call dumpregs_extended
  3331 00000B01 58                      	pop ax			; (preserve so the test al, 8 can use it)
  3332                                  .nonpassnonhit:
  3333 00000B02 E87A05                  	call handle_serial_flags_ctrl_c
  3334                                  
  3335                                  	; al & 4 always set
  3336                                  
  3337 00000B05 8026[0000]E9            	clropt [internalflags2], 		dif2_gg_skip_non_cseip | dif2_gg_skip_cseip | dif2_gg_first_detected
  3339 00000B0A 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
  3340                                  
  3341 00000B0F FF36[0200]              	push word [gg_next_cseip_linear + 2]
  3342 00000B13 FF36[0000]              	push word [gg_next_cseip_linear]
  3343 00000B17 8F06[0000]              	pop word [gg_first_cseip_linear]
  3344 00000B1B 8F06[0200]              	pop word [gg_first_cseip_linear + 2]
  3345                                  
  3346 00000B1F A808                    	test al, 8		; not bb hit, is tt/pp hit ?
  3347 00000B21 751C                    	jnz @FF			; yes -->
  3348                                  
  3349 00000B23 F706[0000]8010          	testopt [internalflags2], dif2_is_pp | dif2_tpg_keep_proceed_bp, 1
  3350 00000B29 7502                    	jnz @F
  3351 00000B2B EB12                    	jmp @FF
  3352                                  
  3353                                  @@:
  3354                                  	lframe near
  3355                                  	lpar dword,	counter
  3356                                  	lpar_return
  3357 00000B2D 5589E5                  	lenter
  3358 00000B30 83460401                	add word [bp + ?counter], 1
  3359 00000B34 83560600                	adc word [bp + ?counter + 2], 0
  3360 00000B38 5D                      	lleave
  3361 00000B39 BA0100                  	mov dx, 1		; skip WHILE
  3362 00000B3C 38C0                    	cmp al, al		; (NC, ZR)
  3363 00000B3E C3                      	retn
  3364                                  
  3365                                  @@:
  3366 00000B3F 31D2                    	xor dx, dx		; no skip WHILE
  3367 00000B41 A802                    	test al, 2		; displayed pass point ?
  3368 00000B43 7503                    	jnz @F			; yes -->
  3369 00000B45 A8FF                    	test al, -1		; NC, NZ (do not skip dump)
  3370                                  		; al & 0Ch is set so this test is NZ
  3371 00000B47 C3                      	retn
  3372                                  
  3373                                  @@:
  3374 00000B48 F606[0300]10            	testopt [internalflags], tt_silent_mode
  3375                                  				; (NC, ZF is ZR if to skip dump)
  3376 00000B4D C3                      	retn
  3377                                  
  3378                                  .actual_hit:
  3379                                  d5	call d5message
  3380                                  d5	asciz "bb hit",13,10
  3381                                  
  3382 00000B4E 31D2                    	xor dx, dx		; no skip WHILE
  3383 00000B50 F9                      	stc
  3384 00000B51 C3                      	retn
  3385                                  
  3386                                  
  3387                                  %if _ATTACH
  3388                                  attach:
  3389                                   %if _BOOTLDR
  3390 00000B52 F606[0100]40            	testopt [internalflags], nodosloaded
  3391 00000B57 7403E9(0000)            	jnz error
  3392                                   %endif
  3393 00000B5C E8(0000)                	call skipwh0
  3394 00000B5F E8(0000)                	nearcall getword
  3395 00000B62 E8(0000)                	call chkeol
  3396 00000B65 F606[0200]40            	testopt [internalflags], tsrmode
  3397 00000B6A 750C                    	jnz @F			; resident -->
  3398 00000B6C BA[0000]                	mov dx, msg.notyettsr
  3399 00000B6F B81101                  	mov ax, 0111h
  3400                                  .specificerror:
  3401 00000B72 E8(0000)                	call setrc
  3402 00000B75 E9(0000)                	jmp putsz_error
  3403                                  
  3404                                  @@:
  3405                                   %if _PM
  3406                                  	call setes2dx
  3407                                   %else
  3408 00000B78 8EC2                    	mov es, dx
  3409                                   %endif
  3410 00000B7A 26813E0000CD20          	cmp word [es:0], 20CDh
  3411 00000B81 7408                    	je @F
  3412 00000B83 BA[0000]                	mov dx, msg.invalidpsp
  3413 00000B86 B81201                  	mov ax, 0112h
  3414 00000B89 EBE7                    	jmp .specificerror
  3415                                  
  3416                                  @@:
  3417 00000B8B 2639161600              	cmp word [es:16h], dx
  3418 00000B90 7508                    	jne @F
  3419 00000B92 BA[0000]                	mov dx, msg.selfownedpsp
  3420 00000B95 B81301                  	mov ax, 0113h
  3421 00000B98 EBD8                    	jmp .specificerror
  3422                                  
  3423                                  @@:
  3424 00000B9A 06                      	push es
  3425 00000B9B 1F                      	pop ds
  3426 00000B9C 16                      	push ss
  3427 00000B9D 07                      	pop es
  3428 00000B9E BE0A00                  	mov si, TPIV
  3429 00000BA1 BF[0000]                	mov di, psp22
  3430 00000BA4 A5                      	movsw
  3431 00000BA5 A5                      	movsw				; save Int22
  3432                                   %if _PM
  3433                                  	mov ax, word [ss:pspdbg]
  3434                                   %else
  3435 00000BA6 8CD0                    	mov ax, ss			; => our process
  3436                                   %endif
  3437 00000BA8 C744FC[D001]            	mov word [ si-4 ], int22
  3438 00000BAD 8944FE                  	mov word [ si-2 ], ax		; set pspInt22 (required)
  3439 00000BB0 BE1600                  	mov si, 16h
  3440 00000BB3 A5                      	movsw				; save parent
  3441 00000BB4 8944FE                  	mov word [ si-2 ], ax		; set pspParent
  3442 00000BB7 16                      	push ss
  3443 00000BB8 1F                      	pop ds
  3444 00000BB9 8026[0200]BF            	clropt [internalflags], tsrmode
  3445 00000BBE BA[0000]                	mov dx, msg.nowattached
  3446 00000BC1 E9(0000)                	jmp putsz
  3447                                  %endif
  3448                                  
  3449                                  
  3450                                  %if _TSR && (_APPLICATION || _DEVICE)
  3451                                  tsr:
  3452                                   %if _BOOTLDR
  3453 00000BC4 F606[0100]40            	testopt [internalflags], nodosloaded
  3454 00000BC9 7403E9(0000)            	jnz error
  3455                                   %endif
  3456 00000BCE E8(0000)                	call guard_re
  3457 00000BD1 46                      	inc si
  3458 00000BD2 AC                      	lodsb
  3459 00000BD3 E8(0000)                	call chkeol
  3460 00000BD6 F606[0200]40            	testopt [internalflags], tsrmode
  3461 00000BDB 7408                    	jz .try			; not yet resident -->
  3462 00000BDD BA[0000]                	mov dx, msg.alreadytsr
  3463 00000BE0 B81401                  	mov ax, 0114h
  3464 00000BE3 EB3C                    	jmp .specificerror_es
  3465                                  .try:
  3466 00000BE5 8B16[0000]              	mov dx, word [pspdbe]
  3467 00000BE9 8B1E[0000]              	mov bx, word [pspdbg]
  3468 00000BED BF0A00                  	mov di, 0Ah
  3469                                  .loop:
  3470                                  %if _PM
  3471                                  	mov cx, dx		; = original segment address
  3472                                  	call ispm
  3473                                  	jnz .rm
  3474                                  	push bx
  3475                                  	mov ax, dx
  3476                                  [cpu 286]
  3477                                  	shr dx, 12
  3478                                  	shl ax, 4		; shift to get a 32-bit linear address
  3479                                  __CPU__
  3480                                  	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                                  	call setrmlimit
  3487                                  	mov di, dx		; -> PSP
  3488                                  	mov dx, bx
  3489                                  	pop bx
  3490                                  	add di, byte 0Ah	; -> PSP termination vector
  3491                                  .rm:
  3492                                  %endif
  3493 00000BF0 8EC2                    	mov es, dx
  3494 00000BF2 268B450C                	mov ax, word [es:(di-0Ah)+16h]
  3495 00000BF6 40                      	inc ax
  3496 00000BF7 7422                    	jz .pspnotfound
  3497 00000BF9 48                      	dec ax
  3498 00000BFA 741F                    	jz .pspnotfound		; parent is invalid -->
  3499                                  %if _PM
  3500                                  	cmp ax, cx
  3501                                  %else
  3502 00000BFC 39D0                    	cmp ax, dx
  3503                                  %endif
  3504 00000BFE 741B                    	je .pspnotfound		; parent is the process itself -->
  3505 00000C00 89C2                    	mov dx, ax
  3506 00000C02 39D8                    	cmp ax, bx
  3507 00000C04 75EA                    	jne .loop		; parent is not us -->
  3508 00000C06 26813D[D001]            	cmp word [es:di], int22
  3509 00000C0B 7506                    	jne .psphooked
  3510 00000C0D 26395D02                	cmp word [es:di+2], bx
  3511 00000C11 7416                    	je .found		; correct vector --> (otherwise: hooked)
  3512                                  .psphooked:
  3513 00000C13 BA[0000]                	mov dx, msg.psphooked
  3514 00000C16 B80F01                  	mov ax, 010Fh
  3515 00000C19 EB06                    	jmp short .specificerror_es
  3516                                  .pspnotfound:
  3517 00000C1B BA[0000]                	mov dx, msg.pspnotfound
  3518 00000C1E B81001                  	mov ax, 0110h
  3519                                  .specificerror_es:
  3520 00000C21 E8(0000)                	call setrc
  3521                                  .putsz_es:
  3522 00000C24 16                      	push ss
  3523 00000C25 07                      	pop es
  3524                                  .putsz:
  3525 00000C26 E9(0000)                	jmp putsz
  3526                                  
  3527                                  .found:
  3528 00000C29 BE[0000]                	mov si, psp22
  3529 00000C2C A5                      	movsw
  3530 00000C2D A5                      	movsw			; write our parent's vector
  3531 00000C2E 83C708                  	add di, 16h-(0Ah+4)
  3532 00000C31 A5                      	movsw			; write our parent
  3533 00000C32 800E[0200]40            	setopt [internalflags], tsrmode	; note that we are resident
  3534                                  %if _PM
  3535                                  	push cx
  3536                                  %else
  3537 00000C37 06                      	push es
  3538                                  %endif
  3539 00000C38 BA[0000]                	mov dx, msg.nowtsr1
  3540 00000C3B E8E6FF                  	call .putsz_es
  3541 00000C3E 58                      	pop ax
  3542 00000C3F BF[0000]                	mov di, line_out
  3543 00000C42 E8(0000)                	call hexword
  3544 00000C45 E8(0000)                	call putsline
  3545 00000C48 BF[0000]                	mov di, psp22
  3546 00000C4B 31C0                    	xor ax, ax
  3547 00000C4D AB                      	stosw
  3548 00000C4E AB                      	stosw
  3549 00000C4F AB                      	stosw			; clear our parent/int22 fields
  3550 00000C50 BA[0000]                	mov dx, msg.nowtsr2
  3551 00000C53 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 00000C55 E81000                  	call silence_init
  3561 00000C58 E8(0000)                	call putsz		; print string
  3562                                  
  3563                                  silence_exit:
  3564 00000C5B F606[0300]10            	testopt [internalflags], tt_silent_mode
  3565 00000C60 7405                    	jz @F
  3566 00000C62 8026[0300]DF            	clropt [internalflags], tt_silence
  3567                                  @@:
  3568 00000C67 C3                      	retn
  3569                                  
  3570                                  
  3571                                  silence_init:
  3572 00000C68 F606[0300]10            	testopt [internalflags], tt_silent_mode
  3573 00000C6D 7405                    	jz @F
  3574 00000C6F 800E[0300]20            	setopt [internalflags], tt_silence
  3575                                  @@:
  3576 00000C74 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 00000C75 E8F0FF                  	call silence_init
  3585 00000C78 E8(0000)                	call putsline
  3586 00000C7B 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 00000C7D F606[0200]80            	testopt [options6], opt6_debug_putrunint
  3598 00000C82 7414                    	jz @F
  3599 00000C84 F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  3600 00000C89 750D                    	jnz @F
  3601 00000C8B E86B07                  	call reset_interrupts
  3602 00000C8E 800E[0100]01            	setopt [internalflags6], dif6_debug_mode
  3603 00000C93 800E[0100]01            	setopt [options6], opt6_debug_mode
  3604                                  @@:
  3605                                  %endif
  3606                                  
  3607                                  %if _DEBUG
  3608                                   %if _DEBUG_COND
  3609 00000C98 F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  3610 00000C9D 7409                    	jz @F
  3611                                   %endif
  3612 00000C9F F606[0200]40            	testopt [options6], opt6_debug_putrunint_early
  3613 00000CA4 7402                    	jz @F
  3614 00000CA6 CC                      	int3
  3615 00000CA7 90                      	nop
  3616                                  @@:
  3617                                  %endif
  3618                                  
  3619                                  %if _AREAS_HOOK_SERVER
  3620                                  	_386_PM_o32		; push ecx
  3621                                  	push cx
  3622                                  	push bx
  3623                                  	_386_PM_o32		; push esi
  3624                                  	push si
  3625                                  
  3626                                  	mov ax, word [run_int]
  3627                                  	cmp ax, int1msg
  3628                                  	je .end_j
  3629                                  	cmp ax, int3msg
  3630                                  	je .end_j
  3631                                  %if _CATCHINT19
  3632                                  	cmp ax, int19msg
  3633                                  	je .end_j
  3634                                  %endif
  3635                                  	cmp ax, progtrm
  3636                                  	jne @F
  3637                                  .end_j:
  3638                                  	jmp .end
  3639                                  
  3640                                  @@:
  3641                                  	_386_PM_o32		; xor ecx, ecx
  3642                                  	xor cx, cx
  3643                                  	call get_cseip_ecx_linear
  3644                                  	mov bx, dx		; bx:ax = linear cs:eip
  3645                                  	push ss
  3646                                  	pop es
  3647                                  	mov di, ddebugareas
  3648                                  	xor cx, cx
  3649                                  
  3650                                  .loop:
  3651                                  %if _PM
  3652                                  	mov dx, word [es:di + areastrucNext + 2]
  3653                                  	mov di, word [es:di + areastrucNext]
  3654                                  	call setes2dx
  3655                                  %else
  3656                                  	les di, [es:di + areastrucNext]
  3657                                  	mov dx, es
  3658                                  %endif
  3659                                  	cmp dx, word [pspdbg]
  3660                                  	je .end
  3661                                  
  3662                                  	push dx
  3663                                  	push di
  3664                                  	push cx
  3665                                  	push bx
  3666                                  	push ax
  3667                                  
  3668                                  	push di
  3669                                  	mov cx, word [es:di + areastrucFunAmount]
  3670                                  	mov di, word [es:di + areastrucFunOffset]
  3671                                  	jcxz .noareafun
  3672                                  .loopareafun:
  3673                                  	cmp bx, word [es:di + areastrucfunLinear + 2]
  3674                                  	jne @F
  3675                                  	cmp ax, word [es:di + areastrucfunLinear]
  3676                                  @@:
  3677                                  	jb .nextareafun
  3678                                  
  3679                                  	cmp bx, word [es:di + areastrucfunLinearEnd + 2]
  3680                                  	jne @F
  3681                                  	cmp ax, word [es:di + areastrucfunLinearEnd]
  3682                                  @@:
  3683                                  	jae .nextareafun
  3684                                  
  3685                                  	push bx
  3686                                  	push ax
  3687                                  	push cx
  3688                                  	push di
  3689                                  
  3690                                  	sub ax, word [es:di + areastrucfunLinear]
  3691                                  	sbb bx, word [es:di + areastrucfunLinear + 2]
  3692                                  	jnz .nextareafun_pop
  3693                                  
  3694                                  	mov cx, word [es:di + areastrucfunListAmount]
  3695                                  	push cx
  3696                                  	mov di, word [es:di + areastrucfunListOffset]
  3697                                  	repne scasw
  3698                                  	pop cx
  3699                                  	jne .nextareafun_pop
  3700                                  	add cx, cx
  3701                                  	dec di
  3702                                  	dec di
  3703                                  	add di, cx
  3704                                  _386_PM	xor ecx, ecx
  3705                                  	mov cx, word [es:di]
  3706                                  	_386_PM_o32
  3707                                  	mov si, word [reg_esp]
  3708                                  	_386_PM_o32
  3709                                  	add si, cx
  3710                                  	push ds
  3711                                  %if _PM
  3712                                  	mov bx, word [reg_ss]
  3713                                  	call test_d_b_bit
  3714                                  	mov ds, bx
  3715                                  	jz .16
  3716                                  .32:
  3717                                  	_386_PM_a32
  3718                                  %else
  3719                                  	mov ds, word [reg_ss]
  3720                                  %endif
  3721                                  .16:
  3722                                  	lodsw
  3723                                  	pop ds
  3724                                  .gotfunction:
  3725                                  	pop di
  3726                                  	pop cx
  3727                                  	pop bx			; (discard)
  3728                                  	pop bx
  3729                                  
  3730                                  	xchg dx, ax
  3731                                  	mov bx, word [reg_cs]	; bx:dx = cs:ip
  3732                                  	call getlinear_16bit	; dx:ax = linear
  3733                                  	mov bx, dx		; bx:ax = linear
  3734                                  	jmp .noareafun
  3735                                  
  3736                                  .nextareafun_pop:
  3737                                  	pop di
  3738                                  	pop cx
  3739                                  	pop ax
  3740                                  	pop bx
  3741                                  .nextareafun:
  3742                                  	add di, AREASTRUCFUN_size
  3743                                  	loop .loopareafun
  3744                                  .noareafun:
  3745                                  	pop di
  3746                                  
  3747                                  	mov cx, word [es:di + areastrucSubAmount]
  3748                                  	mov di, word [es:di + areastrucSubOffset]
  3749                                  	jcxz .noareasub
  3750                                  .loopareasub:
  3751                                  	cmp bx, word [es:di + areastrucsubLinear + 2]
  3752                                  	jne @F
  3753                                  	cmp ax, word [es:di + areastrucsubLinear]
  3754                                  @@:
  3755                                  	jb .nextareasub
  3756                                  
  3757                                  	cmp bx, word [es:di + areastrucsubLinearEnd + 2]
  3758                                  	jne @F
  3759                                  	cmp ax, word [es:di + areastrucsubLinearEnd]
  3760                                  @@:
  3761                                  	jae .nextareasub
  3762                                  
  3763                                  	push bx
  3764                                  	push ax
  3765                                  	push cx
  3766                                  	push di
  3767                                  
  3768                                  	sub ax, word [es:di + areastrucsubLinear]
  3769                                  	sbb bx, word [es:di + areastrucsubLinear + 2]
  3770                                  	jnz .nextareasub_pop
  3771                                  
  3772                                  	mov dx, ax		; = ip
  3773                                  	mov si, word [es:di + areastrucsubListOffset]
  3774                                  	mov cx, word [es:di + areastrucsubListAmount]
  3775                                  .looparea:
  3776                                  	es lodsw
  3777                                  	cmp dx, ax
  3778                                  	es lodsw
  3779                                  	jb .nextarea
  3780                                  	cmp dx, ax
  3781                                  	jae .nextarea
  3782                                  	es lodsw
  3783                                  	mov bx, ax		; es:bx -> area message
  3784                                  	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                                  	cmp word [es:bx], 13 | (10 << 8)
  3796                                  				; is it with an initial linebreak ?
  3797                                  	jne @F			; no -->
  3798                                  	testopt [serial_flags], sf_use_serial
  3799                                  	jz @F			; if not serial -->
  3800                                  	inc dx
  3801                                  	inc dx			; skip the linebreak
  3802                                  @@:
  3803                                  	 push es
  3804                                  	 pop ds			; => our area hook client's data selector
  3805                                  	call putsz		; display ds:dx -> ASCIZ message
  3806                                  	 push ss
  3807                                  	 pop ds			; reset ds
  3808                                  	pop di
  3809                                  	pop cx
  3810                                  	pop ax
  3811                                  	pop bx
  3812                                  
  3813                                  	pop ax
  3814                                  	pop bx
  3815                                  	pop cx
  3816                                  	pop di
  3817                                  	pop dx
  3818                                  
  3819                                  	jmp .end
  3820                                  
  3821                                  .nextarea:
  3822                                  	add si, 4
  3823                                  	loop .looparea
  3824                                  
  3825                                  .nextareasub_pop:
  3826                                  	pop di
  3827                                  	pop cx
  3828                                  	pop ax
  3829                                  	pop bx
  3830                                  .nextareasub:
  3831                                  	add di, AREASTRUCSUB_size
  3832                                  	loop .loopareasub
  3833                                  .noareasub:
  3834                                  
  3835                                  .next:
  3836                                  	pop ax
  3837                                  	pop bx
  3838                                  	pop cx
  3839                                  	pop di
  3840                                  %if _PM
  3841                                  	pop dx
  3842                                  	call setes2dx
  3843                                  %else
  3844                                  	pop es
  3845                                  %endif
  3846                                  	loop .loop_j
  3847                                  	jmp .end
  3848                                  
  3849                                  .loop_j:
  3850                                  	jmp .loop
  3851                                  
  3852                                  .end:
  3853                                  	_386_PM_o32		; pop esi
  3854                                  	pop si
  3855                                  	pop bx
  3856                                  	_386_PM_o32		; pop ecx
  3857                                  	pop cx
  3858                                  %endif
  3859 00000CA8 16                      	 push ss
  3860 00000CA9 07                      	 pop es
  3861                                  
  3862                                  .noarea:
  3863 00000CAA 8B16[0000]              	mov dx, word [run_int]
  3864 00000CAE 81FA[0000]              	cmp dx, progtrm
  3865 00000CB2 7515                    	jne .done
  3866                                  
  3867 00000CB4 B8FFFF                  	mov ax, -1
  3868 00000CB7 E8(0000)                	call InDOS
  3869 00000CBA 7504                    	jnz .no_int21_4D
  3870                                  
  3871 00000CBC B44D                    	mov ah, 4Dh
  3872 00000CBE CD21                    	int 21h
  3873                                  .no_int21_4D:
  3874 00000CC0 A3[0000]                	mov word [usertermcode], ax
  3875 00000CC3 BF[0000]                	mov di, progexit
  3876 00000CC6 E8(0000)                	call hexword
  3877                                  .done:
  3878 00000CC9 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                                  	call resetmode
  3896                                  %endif
  3897 00000CCC E899FF                  	call silence_init
  3898 00000CCF E8ABFF                  	call putrunint
  3899 00000CD2 E886FF                  	call silence_exit
  3900                                  %if _CATCHINT19
  3901 00000CD5 81FA[0000]              	cmp dx, int19msg
  3902 00000CD9 7409                    	je .noregs		; if it terminated, skip the registers
  3903                                  %endif
  3904 00000CDB 81FA[0000]              	cmp dx, progtrm
  3905 00000CDF 7403                    	je .noregs		; if it terminated, skip the registers
  3906 00000CE1 E89203                  	call dumpregs_extended_silent
  3907                                  .noregs:
  3908 00000CE4 E84603                  	call terminate_silent_dump.if_nonnull
  3909 00000CE7 E8(0000)                	call silence_dump
  3910                                  
  3911 00000CEA F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  3912 00000CEF 7407                    	jz @F
  3913 00000CF1 F606[0200]20            	testopt [options], gg_unexpected_no_repeat
  3914 00000CF6 EB05                    	jmp @FF
  3915                                  @@:
  3916 00000CF8 F606[0200]40            	testopt [options], tp_unexpected_no_repeat
  3917                                  @@:
  3918 00000CFD 7406                    	jz @F
  3919 00000CFF C706[0000][0000]        	mov word [lastcmd], dmycmd
  3920                                  @@:
  3921                                  
  3922 00000D05 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 00000D08 F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  3962 00000D0D 7403E98A00              	jnz .proceedbreakpoint
  3963                                  
  3964                                  %if _PM
  3965                                  	call resetmode
  3966                                  %endif
  3967 00000D12 31C9                    	xor cx, cx
  3968 00000D14 E8(0000)                	call getcseipbyte
  3969 00000D17 3CCD                    	cmp al, 0CDh		; int opcode?
  3970 00000D19 7403E98100              	jne .isstdtrace		; no -->
  3971 00000D1E 41                      	inc cx
  3972 00000D1F E8(0000)                	call getcseipbyte
  3973 00000D22 3C03                    	cmp al, 3
  3974 00000D24 7479                    	je .isstdtrace		; int 3 opcode -->
  3975 00000D26 F606[0000]02            	testopt [options], traceints	; TM=1?
  3976 00000D2B 7503E9B400              	jz isstdtraceX
  3977                                  %if _IMMASM
  3978 00000D30 F606[0300]02            	testopt [internalflags6], dif6_immasm
  3979 00000D35 7403E9AA00              	jnz isstdtraceX
  3980                                  %endif
  3981 00000D3A 3C01                    	cmp al, 1
  3982 00000D3C 7461                    	je .isstdtrace		; int 1 opcode -->
  3983                                  
  3984                                  		; TM==1, single-step into the INT
  3985 00000D3E 88C3                    	mov bl, al
  3986                                  %if _PM
  3987                                  	call ispm
  3988                                  	jz .singlestep_into_interrupt_pm
  3989                                  %endif
  3990 00000D40 B700                    	mov bh, 0
  3991 00000D42 1E                      	push ds
  3992 00000D43 31C0                    	xor ax, ax
  3993 00000D45 8ED8                    	mov ds, ax
  3994 00000D47 D1E3                    	shl bx, 1
  3995 00000D49 D1E3                    	shl bx, 1
  3996 00000D4B C537                    	lds si, [bx]
  3997 00000D4D FA                      	cli
  3998 00000D4E 8A04                    	mov al, byte [si]
  3999 00000D50 FE04                    	inc byte [si]
  4000 00000D52 3804                    	cmp byte [si], al
  4001 00000D54 8804                    	mov byte [si], al
  4002 00000D56 FB                      	sti
  4003 00000D57 8CDB                    	mov bx, ds		; bx:si-> interrupt handler (RM, 16 bit)
  4004 00000D59 89D8                    	mov ax, bx
  4005 00000D5B 1F                      	pop ds
  4006 00000D5C 753E                    	jne .singlestep_into_interrupt_setbp
  4007                                  
  4008                                  		; The interrupt handler is in a ROM.
  4009                                  %if 0
  4010                                  	jmp short isstdtraceX
  4011                                  %else
  4012 00000D5E 8736[0000]              	xchg si, word [reg_eip]
  4013 00000D62 8706[0000]              	xchg ax, word [reg_cs]	; get cs:ip, set interrupt handler address
  4014 00000D66 8B0E[0000]              	mov cx, word [reg_efl]	; get flags
  4015 00000D6A 1E                      	push ds
  4016 00000D6B 8B1E[0000]              	mov bx, word [reg_esp]
  4017 00000D6F 8E1E[0000]              	mov ds, word [reg_ss]	; ds:bx-> debuggee stack
  4018 00000D73 83EB06                  	sub bx, byte 6		; reserve enough space for flags, cs, ip
  4019 00000D76 46                      	inc si
  4020 00000D77 46                      	inc si			; skip CDh xxh opcode
  4021 00000D78 894F04                  	mov word [bx+4], cx
  4022 00000D7B 894702                  	mov word [bx+2], ax
  4023 00000D7E 8937                    	mov word [bx+0], si	; save flags, cs, ip on stack
  4024 00000D80 1F                      	pop ds
  4025 00000D81 891E[0000]              	mov word [reg_esp], bx	; update sp
  4026 00000D85 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 00000D8A C706[0000][0000]        	mov word [run_int], int1msg
  4033 00000D90 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 00000D96 B90800                  	mov cx, 8
  4037 00000D99 31C0                    	xor ax, ax		; NC, ZR
  4038 00000D9B C3                      	retn
  4039                                  
  4040                                  %endif
  4041                                  %if _PM
  4042                                  .singlestep_into_interrupt_pm:
  4043                                  	mov ax, 0204h
  4044                                  	int 31h
  4045                                  	mov bx, cx
  4046                                  	_386_o32	; mov esi, edx
  4047                                  	mov si, dx		; bx:(e)si-> interrupt handler
  4048                                  	test bl, 4		; is it a LDT selector? (NC)
  4049                                  	jz isstdtraceX		; no -->
  4050                                  %endif
  4051                                  .singlestep_into_interrupt_setbp:
  4052                                  .proceedbreakpoint:
  4053 00000D9C E99504                  	jmp proceedbreakpoint
  4054                                  
  4055                                  .isstdtrace:
  4056                                  %if _PM
  4057                                  	call ispm
  4058                                  	jz .notdpmientry	; already in PM -->
  4059                                  	mov ax, w[reg_eip]	; is this a switch to protected mode ?
  4060                                  	cmp ax, w[dpmiwatch+0]
  4061                                  	jne .notdpmientry
  4062                                  	mov ax, w[reg_cs]
  4063                                  	cmp ax, w[dpmiwatch+2]
  4064                                  	je isdpmientry		; yes, catch it --> (this means really "go")
  4065                                  .notdpmientry:
  4066                                  %endif
  4067 00000D9F 800E[0100]01            	or byte [reg_efl+1], 1	; set single-step mode (cleared when returning into DEBUG)
  4068 00000DA4 31C9                    	xor cx, cx
  4069 00000DA6 E85100                  	call skipprefixes
  4070 00000DA9 3C9C                    	cmp al, 9Ch		; opcode "PUSHF"?
  4071 00000DAB 7517                    	jnz .notpushf
  4072                                  %if _BREAKPOINTS
  4073 00000DAD E82005                  	call run_with_bb
  4074 00000DB0 B400                    	mov ah, 0
  4075 00000DB2 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 00000DB3 06                      	push es
  4084                                  %if _PM
  4085                                  	mov bx, word [reg_ss]	; get ss selector into bx
  4086                                  	mov es, bx
  4087                                  _386	call test_d_b_bit	; check whether a 32-bit ss
  4088                                  %else
  4089 00000DB4 8E06[0000]              	mov es, word [reg_ss]
  4090                                  %endif
  4091                                  	_386_PM_o32	; mov ebx, dword [reg_esp]
  4092 00000DB8 8B1E[0000]              	mov bx, word [reg_esp]	; es:(e)bx-> debuggee's stack
  4093                                  _386_PM	jz .pushf_16
  4094                                  _386_PM	and byte [es:ebx+1], ~1	; clear TF
  4095                                  _386_PM	jmp short .pushf_common
  4096                                  .pushf_16:
  4097 00000DBC 26806701FE              	and byte [es:bx+1], ~1	; clear TF
  4098                                  .pushf_common:
  4099 00000DC1 07                      	pop es
  4100 00000DC2 EB06                    	jmp short .checkreturn
  4101                                  .notpushf:
  4102                                  %if _BREAKPOINTS
  4103 00000DC4 E80905                  	call run_with_bb
  4104 00000DC7 B400                    	mov ah, 0
  4105 00000DC9 9C                      	pushf
  4106                                  %else
  4107                                  	call run
  4108                                  	xor cx, cx
  4109                                  	xor ax, ax
  4110                                  %endif
  4111                                  .checkreturn:
  4112 00000DCA 813E[0000][0000]        	cmp word [run_int], int1msg
  4113 00000DD0 7509                    	jne .nomatch
  4114 00000DD2 80C908                  	or cl, 8
  4115                                  %if _BREAKPOINTS
  4116 00000DD5 9D                      	popf			; CF
  4117 00000DD6 7308                    	jnc .ret_NZ_NC
  4118                                  %endif
  4119 00000DD8 38C0                    	cmp al, al		; if correct interrupt (ZR, NC)
  4120 00000DDA C3                      	retn
  4121                                  
  4122                                  .nomatch:
  4123                                  %if _BREAKPOINTS
  4124 00000DDB 9D                      	popf			; CF
  4125 00000DDC 7302                    	jnc .ret_NZ_NC
  4126                                  %endif
  4127 00000DDE F9                      	stc
  4128 00000DDF C3                      	retn
  4129                                  
  4130                                  %if _BREAKPOINTS
  4131                                  .ret_NZ_NC:
  4132 00000DE0 80C904                  	or cl, 4		; (NZ, NC)
  4133 00000DE3 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 00000DE4 B90200                  	mov cx, 2
  4144 00000DE7 E84600                  	call iswriteablecseip	; is it ROM ?
  4145 00000DEA 72B3                    	jc traceone.isstdtrace	; is read-only -->
  4146 00000DEC 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                                  	_386_PM_o32	; mov esi, dword [reg_eip]
  4152 00000DF0 8B36[0000]              	mov si, word [reg_eip]
  4153                                  	_386_PM_o32	; add esi, byte 2
  4154 00000DF4 83C602                  	add si, byte 2		; ! do not remove the byte override, else o32 won't work
  4155 00000DF7 E93A04                  	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 00000DFA E8(0000)                	call getcseipbyte
  4165 00000DFD 3C26                    	cmp al, 26h
  4166 00000DFF 742A                    	je .prefix		; ES
  4167 00000E01 3C2E                    	cmp al, 2Eh
  4168 00000E03 7426                    	je .prefix		; CS
  4169 00000E05 3C36                    	cmp al, 36h
  4170 00000E07 7422                    	je .prefix		; SS
  4171 00000E09 3C3E                    	cmp al, 3Eh
  4172 00000E0B 741E                    	je .prefix		; DS
  4173 00000E0D 3CF0                    	cmp al, 0F0h
  4174 00000E0F 741A                    	je .prefix		; LOCK
  4175 00000E11 3CF3                    	cmp al, 0F3h
  4176 00000E13 7416                    	je .prefix		; REPZ
  4177 00000E15 3CF2                    	cmp al, 0F2h
  4178 00000E17 7412                    	je .prefix		; REPNZ
  4179 00000E19 EB14                    	_no386_jmps .noprefix	; no 386, following aren't prefixes (invalid opcodes on 186+) -->
  4180 00000E1B 3C64                    	cmp al, 64h
  4181 00000E1D 740C                    	je .prefix		; FS
  4182 00000E1F 3C65                    	cmp al, 65h
  4183 00000E21 7408                    	je .prefix		; GS
  4184 00000E23 3C66                    	cmp al, 66h
  4185 00000E25 7404                    	je .prefix		; o32/o16
  4186 00000E27 3C67                    	cmp al, 67h
  4187 00000E29 7504                    	jne .noprefix		; not a32/a16
  4188                                  .prefix:
  4189 00000E2B 41                      	inc cx
  4190                                  	; jmp short .
  4191 00000E2C 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 00000E2E 49                      	dec cx			; back to 07FFFh
  4194                                  .noprefix:
  4195 00000E2F 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 00000E30 E8(0000)                	call getcseipbyte	; get byte at CS:EIP+CX
  4203 00000E33 88C4                    	mov ah, al
  4204 00000E35 34FF                    	xor al, 0FFh
  4205 00000E37 E8(0000)                	call setcseipbyte
  4206 00000E3A 720E                    	jc .return
  4207 00000E3C E8(0000)                	call getcseipbyte
  4208 00000E3F 38C4                    	cmp ah, al     		; is it ROM?
  4209 00000E41 F9                      	stc
  4210 00000E42 7406                    	jz .return
  4211 00000E44 88E0                    	mov al, ah
  4212 00000E46 E8(0000)                	call setcseipbyte
  4213 00000E49 F8                      	clc
  4214                                  .return:
  4215 00000E4A 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 [4B0E]                  	dw .code
  4245                                  
  4246                                  	usesection lDEBUG_CODE
  4246          ------------------       note: usesection lDEBUG_CODE
  4247                                  .code:
  4248 00000E4B FB                      	sti
  4249                                  %endif
  4250                                  %if _PM || _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  4251                                  debuggerexception:
  4252 00000E4C FC                      	cld
  4253 00000E4D 16                      	push ss
  4254 00000E4E 1F                      	pop ds
  4255                                  %if _DEBUG && _DEBUG_COND
  4256 00000E4F F606[0000]80            	testopt [options6], opt6_debug_exception
  4257 00000E54 7414                    	jz @F
  4258 00000E56 F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  4259 00000E5B 750D                    	jnz @F
  4260 00000E5D E89905                  	call reset_interrupts
  4261 00000E60 800E[0100]01            	setopt [internalflags6], dif6_debug_mode
  4262 00000E65 800E[0100]01            	setopt [options6], opt6_debug_mode
  4263                                  @@:
  4264                                  %endif
  4265                                  
  4266                                  %if _DEBUG
  4267                                   %if _DEBUG_COND
  4268 00000E6A F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  4269 00000E6F 7409                    	jz @F
  4270                                   %endif
  4271 00000E71 F606[0000]40            	testopt [options6], opt6_debug_exception_early
  4272 00000E76 7402                    	jz @F
  4273 00000E78 CC                      	int3
  4274 00000E79 90                      	nop
  4275                                  @@:
  4276                                  %endif
  4277 00000E7A E8(0000)                	call unhack		; sets es to ss
  4278                                  
  4279                                  %if _AREAS
  4280 00000E7D 8CCB                    	mov bx, cs
  4281 00000E7F 3B1E[0200]              	cmp bx, word [exception_csip + 2]
  4282 00000E83 7532                    	jne .unknownarea
  4283 00000E85 A1[0000]                	mov ax, word [exception_csip]
  4284 00000E88 BF[A000]                	mov di, areafunctions
  4285 00000E8B B90500                  	mov cx, areafunctions.amount
  4286 00000E8E F2AF                    	repne scasw
  4287 00000E90 7508                    	jne .unknownfunction
  4288 00000E92 BB[0000]                	mov bx, exception_stack
  4289 00000E95 035D08                  	add bx, word [di - areafunctions - 2 + areafunctions.skip]
  4290 00000E98 8B07                    	mov ax, [bx]
  4291                                  .gotfunction:
  4292                                  
  4293                                  .unknownfunction:
  4294 00000E9A 89C2                    	mov dx, ax		; = ip
  4295 00000E9C BE[3000]                	mov si, areas
  4296 00000E9F B90E00                  	mov cx, areas.amount
  4297                                  .looparea:
  4298 00000EA2 AD                      	lodsw
  4299 00000EA3 39C2                    	cmp dx, ax
  4300 00000EA5 AD                      	lodsw
  4301 00000EA6 720B                    	jb .nextarea
  4302 00000EA8 39C2                    	cmp dx, ax
  4303 00000EAA 7307                    	jae .nextarea
  4304 00000EAC AD                      	lodsw
  4305 00000EAD 92                      	xchg ax, dx
  4306 00000EAE E8(0000)                	call putsz
  4307 00000EB1 EB04                    	jmp .donearea
  4308                                  .nextarea:
  4309 00000EB3 AD                      	lodsw
  4310 00000EB4 AD                      	lodsw
  4311 00000EB5 E2EB                    	loop .looparea
  4312                                  
  4313                                  .donearea:
  4314                                  .unknownarea:
  4315                                  %endif
  4316 00000EB7 E8F0FD                  	call putrunint.noarea
  4317                                  %if _EXCCSIP
  4318 00000EBA BF[0000]                	mov di, exccsip
  4319 00000EBD A1[0200]                	mov ax, word [exception_csip + 2]
  4320 00000EC0 E8(0000)                	call hexword
  4321 00000EC3 47                      	inc di
  4322 00000EC4 A1[0000]                	mov ax, word [exception_csip]
  4323 00000EC7 E8(0000)                	call hexword
  4324                                  
  4325 00000ECA BA[0000]                	mov dx, excloc
  4326 00000ECD E8(0000)                	call putsz
  4327                                  %endif
  4328                                  %if _DEBUG
  4329                                   %if _DEBUG_COND
  4330 00000ED0 F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  4331 00000ED5 7408                    	jz @F
  4332                                   %endif
  4333 00000ED7 F606[0000]20            	testopt [options6], opt6_debug_exception_late
  4334 00000EDC 7401                    	jz @F
  4335 00000EDE CC                      	int3
  4336                                  @@:
  4337                                  %endif
  4338 00000EDF 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 00000038 [0000][0000][0000]-     	areadefine hh_indirection_memory_access
  4370 0000003E 0000               
  4371                                  %else
  4372                                  	areadefine hh_code1_indirection_memory_access, hh_indirection_memory_access
  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][CD16][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                                  	areadefine hh_indirection_memory_access
  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 000000A0 [0000][0000][0000]-     	repeatdw AREAFUNCTIONS
  4414 000000A6 [0000][0000]       
  4415                                  .end:
  4416                                  .amount: equ (.end - .) / 2
  4417                                  .skip:
  4418 000000AA 040004000400020002-     	repeatdw AREAFUNCTIONSSKIP
  4418 000000B3 00                 
  4419                                  
  4420                                  
  4421                                  %if _AREAS_HOOK_CLIENT
  4422                                  areas_struc:
  4423                                  	istruc AREASTRUC
  4424                                  at areastrucEntry
  4425                                  	stc
  4426                                  	retf
  4427                                  at areastrucNext,	dd -1
  4428                                  at areastrucPrev,	dd -1
  4429                                  at areastrucSubAmount,	dw areas_sub_amount
  4430                                  at areastrucSubOffset,	dw areas_sub
  4431                                  at areastrucFunAmount,	dw 1
  4432                                  at areastrucFunOffset,	dw areas_fun
  4433                                  	iend
  4434                                  
  4435                                  areas_sub:
  4436                                  	istruc AREASTRUCSUB
  4437                                  at areastrucsubLinear,		dd 0
  4438                                  at areastrucsubLinearEnd
  4439                                   %ifn _LINK
  4440                                  				dd ldebug_code_size
  4441                                   %else
  4442                                  				dw behind_code wrt lDEBUG_CODE
  4443                                   %endif
  4444                                  at areastrucsubListOffset,	dw areas
  4445                                  at areastrucsubListAmount,	dw areas.amount
  4446                                  	iend
  4447                                  %if _DUALCODE && _EXPRDUALCODE
  4448                                  	istruc AREASTRUCSUB
  4449                                  at areastrucsubLinear,		dd 0
  4450                                  at areastrucsubLinearEnd
  4451                                   %ifn _LINK
  4452                                  				dd ldebug_code2_size
  4453                                   %else
  4454                                  				dw behind_code2 wrt lDEBUG_CODE2
  4455                                   %endif
  4456                                  at areastrucsubListOffset,	dw areas2
  4457                                  at areastrucsubListAmount,	dw areas2.amount
  4458                                  	iend
  4459                                  %endif
  4460                                  areas_sub_amount equ ($ - areas_sub) / AREASTRUCSUB_size
  4461                                  
  4462                                  areas_fun:
  4463                                  	istruc AREASTRUCFUN
  4464                                  at areastrucfunLinear,		dd 0
  4465                                  at areastrucfunLinearEnd
  4466                                   %ifn _LINK
  4467                                  				dd ldebug_code_size
  4468                                   %else
  4469                                  				dw behind_code wrt lDEBUG_CODE
  4470                                   %endif
  4471                                  at areastrucfunListOffset,	dw areafunctions
  4472                                  at areastrucfunListAmount,	dw areafunctions.amount
  4473                                  	iend
  4474                                  %endif
  4475                                  
  4476                                  	usesection lDEBUG_CODE
  4476          ------------------       note: usesection lDEBUG_CODE
  4477                                  %endif
  4478                                  
  4479                                  
  4480                                  %if _PM
  4481                                  [cpu 386]
  4482                                  		; INP:	dh = flags as for pp2,pp3,pp5 (1 = ASIZE, 2 = OSIZE)
  4483                                  		; OUT:	dh = flags as used by pp3,pp5 (1 = A32, 2 = O32)
  4484                                  pp_fix32bitflags: section_of_function
  4485                                  	call test_d_b_bit
  4486                                  	jz .16
  4487                                  	xor dh, 1|2		; toggle OSIZE and ASIZE (once)
  4488                                  .16:
  4489                                  	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 00000EE2 E8(0000)                	call enable_rh
  4497                                  %endif
  4498 00000EE5 C706[0000][E20E]        	mov word [lastcmd], pp
  4499 00000EEB 800E[0100]10            	setopt [internalflags2], dif2_is_pp
  4500 00000EF0 E80E06                  	call parse_pt		; process arguments
  4501                                  
  4502                                  		; Do it <BX:CX=count> times.  First check the type of instruction.
  4503                                  pp1:
  4504 00000EF3 53                      	push bx
  4505 00000EF4 51                      	push cx			; save bx:cx
  4506                                  %if _PM
  4507                                  	call resetmode
  4508                                  %endif
  4509 00000EF5 BA0F00                  	mov dx, 15		; DL = number of bytes to go; DH = prefix flags.
  4510 00000EF8 8B1E[0000]              	mov bx, word [reg_cs]
  4511                                  	_386_PM_o32	; mov esi, dword [reg_eip]
  4512 00000EFC 8B36[0000]              	mov si, word [reg_eip]
  4513                                  pp2:
  4514 00000F00 E8C703                  	call pp16		; get next instruction byte into AL
  4515 00000F03 BF[0000]                	mov di, ppbytes
  4516 00000F06 B9[0000]                	mov cx, PPLEN
  4517 00000F09 A2[0000]                	mov byte [pp_instruction], al
  4518 00000F0C F2AE                    	repne scasb
  4519 00000F0E 752B                    	jne pp5			; if not one of these -->
  4520                                  %if _LINK_COMPAT
  4521 00000F10 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 00000F14 A880                    	test al, PP_PREFIX	; prefix ?
  4526 00000F16 740F                    	jz pp3			; no -->
  4527 00000F18 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 00000F1A FECA                    	dec dl
  4533 00000F1C 75E2                    	jnz pp2			; if not out of bytes -->
  4534 00000F1E BA[0000]                	mov dx, msg.warnprefix
  4535 00000F21 E8(0000)                	call putsz
  4536 00000F24 E9B500                  	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                                  _386_PM	call pp_fix32bitflags
  4543                                  	_386_PM_o32
  4544 00000F27 8936[0000]              	mov word [pp_operand], si
  4545 00000F2B A840                    	test al, PP_VARSIZ	; different opcode length depends on OSIZE ?
  4546 00000F2D 7405                    	jz .ignoreosize		; no -->
  4547 00000F2F 80E602                  	and dh, 2
  4548 00000F32 00F0                    	add al, dh
  4549                                  .ignoreosize:
  4550 00000F34 83E007                  	and ax, PP_SIZ_MASK
  4551                                  _386_PM	movzx eax, ax		; clear high word (in case it counts)
  4552                                  	_386_PM_o32	; add esi, eax
  4553 00000F37 01C6                    	add si, ax
  4554 00000F39 EB55                    	jmp pp10
  4555                                  
  4556                                  
  4557                                  pp5:
  4558                                  _386_PM	call pp_fix32bitflags
  4559 00000F3B 3CFF                    	cmp al, 0FFh		; FF/2 or FF/3 indirect NEAR or FAR call ?
  4560 00000F3D 7403E99A00              	jne pp12		; no, just an ordinary instruction -->
  4561 00000F42 E88503                  	call pp16		; get MOD REG R/M byte
  4562 00000F45 24F7                    	and al, ~ (1 << 3)	; clear lowest bit of REG field (/3 to /2)
  4563 00000F47 3410                    	xor al, 2 << 3		; /3 or /2 to /0
  4564 00000F49 A838                    	test al, 7 << 3
  4565 00000F4B 7403E98C00              	jnz pp12		; if not FF/2 or FF/3 -->
  4566 00000F50 3CC0                    	cmp al, 0C0h		; mod = 3 ?
  4567 00000F52 733C                    	jae .adjust0		; if just a register -->
  4568 00000F54 F6C601                  	test dh, 1
  4569 00000F57 750E                    	jnz .a32		; if 32-bit addressing -->
  4570 00000F59 3C06                    	cmp al, 6		; mod = 0 r/m = 6 would encode bp ?
  4571 00000F5B 7431                    	je .adjust2		; if just plain disp16 -->
  4572 00000F5D 3C40                    	cmp al, 40h
  4573 00000F5F 722F                    	jb .adjust0		; if indirect register -->
  4574 00000F61 3C80                    	cmp al, 80h
  4575 00000F63 722A                    	jb .adjust1		; if disp8[reg(s)]
  4576 00000F65 EB27                    	jmp short .adjust2	; it's disp16[reg(s)]
  4577                                  
  4578                                  		; Handle 32-bit addressing (A32 ModR/M referencing memory)
  4579                                  .a32:
  4580 00000F67 3C05                    	cmp al, 5		; mod = 0 and r/m = 5 (would encode ebp) ?
  4581 00000F69 7421                    	je .adjust4		; if just plain disp32 -->
  4582 00000F6B 3404                    	xor al, 4		; 4 to 0 (r/m 4 would encode esp)
  4583 00000F6D A807                    	test al, 7		; 0 if r/m would encode esp
  4584 00000F6F 7513                    	jnz .a32_nosib		; if no SIB byte -->
  4585 00000F71 86C4                    	xchg al, ah
  4586 00000F73 E85403                  	call pp16
  4587 00000F76 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 00000F78 A8C0                    	test al, 0C0h		; is it mod = 0 ?
  4594 00000F7A 7508                    	jnz @F			; no, not a special case -->
  4595 00000F7C 80E407                  	and ah, 7
  4596 00000F7F 80FC05                  	cmp ah, 5		; is it base = 5 ?
  4597 00000F82 7408                    	je .adjust4		; yes, special case encoding of disp32 -->
  4598                                  @@:
  4599                                  .a32_nosib:
  4600 00000F84 3C40                    	cmp al, 40h
  4601 00000F86 7208                    	jb .adjust0		; if indirect register -->
  4602 00000F88 3C80                    	cmp al, 80h
  4603 00000F8A 7203                    	jb .adjust1		; if disp8[reg(s)] -->
  4604                                  				; otherwise, it's disp32[reg(s)]
  4605                                  .adjust4:
  4606                                  	_386_PM_o32	; inc esi
  4607 00000F8C 46                      	inc si			; skip an instruction byte
  4608                                  	_386_PM_o32	; inc esi
  4609 00000F8D 46                      	inc si			; skip an instruction byte
  4610                                  .adjust2:
  4611                                  	_386_PM_o32	; inc esi
  4612 00000F8E 46                      	inc si			; skip an instruction byte
  4613                                  .adjust1:
  4614                                  	_386_PM_o32	; inc esi
  4615 00000F8F 46                      	inc si			; skip an instruction byte
  4616                                  .adjust0:
  4617                                  
  4618                                  pp10:
  4619                                  	_386_PM_o32
  4620 00000F90 56                      	push si
  4621                                  
  4622 00000F91 803E[0000]E8            	cmp byte [pp_instruction], 0E8h
  4623 00000F96 7534                    	jne .done
  4624                                  
  4625                                  	_386_PM_o32
  4626 00000F98 8B36[0000]              	mov si, word [pp_operand]
  4627                                  
  4628                                  _386_PM	xor eax, eax
  4629 00000F9C E82B03                  	call pp16
  4630 00000F9F 86C4                    	xchg al, ah
  4631 00000FA1 E82603                  	call pp16
  4632 00000FA4 86C4                    	xchg al, ah
  4633                                  _386_PM	jmp @F
  4634 00000FA6 F6C602                  	test dh, 2
  4635 00000FA9 7521                    	jnz .notcallrel16
  4636                                  @@:
  4637                                  _386_PM	test dh, 2
  4638                                  _386_PM	jz @F
  4639                                  
  4640                                  _386_PM	rol eax, 16
  4641                                  _386_PM	call pp16
  4642                                  _386_PM	xchg al, ah
  4643                                  _386_PM	call pp16
  4644                                  _386_PM	xchg al, ah
  4645                                  _386_PM	rol eax, 16
  4646                                  @@:
  4647                                  	_386_PM_o32
  4648 00000FAB 01C6                    	add si, ax
  4649 00000FAD B20F                    	mov dl, 15		; number of bytes to go
  4650                                  .loop:
  4651 00000FAF E81803                  	call pp16
  4652 00000FB2 3CCB                    	cmp al, 0CBh		; retf ?
  4653 00000FB4 7417                    	je .trace
  4654 00000FB6 3CCA                    	cmp al, 0CAh		; retf imm16 ?
  4655 00000FB8 7413                    	je .trace
  4656 00000FBA 3CCF                    	cmp al, 0CFh		; iret ?
  4657 00000FBC 740F                    	je .trace
  4658 00000FBE BF[0000]                	mov di, ppbytes
  4659 00000FC1 B9[0000]                	mov cx, PPLEN_ONLY_PREFIXES
  4660 00000FC4 F2AE                    	repne scasb
  4661 00000FC6 7504                    	jne .done
  4662                                  				; if one of the prefixes
  4663 00000FC8 FECA                    	dec dl
  4664 00000FCA 75E3                    	jnz .loop		; if not out of bytes -->
  4665                                  
  4666                                  				; fall through: do not trace
  4667                                  .notcallrel16:
  4668                                  .done:
  4669 00000FCC A8                      	db __TEST_IMM8		; (skip stc, NC)
  4670                                  .trace:
  4671 00000FCD F9                      	stc			; trace
  4672                                  	_386_PM_o32
  4673 00000FCE 5E                      	pop si
  4674                                  
  4675 00000FCF 720B                    	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                                  _386_PM	call test_d_b_bit
  4683                                  _386_PM	jnz .32			; full 32-bit offset valid -->
  4684                                  _386_PM	movzx esi, si		; clear high word here
  4685                                  .32:
  4686                                  @@:
  4687 00000FD1 E86002                  	call proceedbreakpoint	; run until the breakpoint is hit
  4688 00000FD4 7254                    	jc pp15			; unexpected -->
  4689                                  %if _BREAKPOINTS
  4690 00000FD6 7515                    	jnz pp12.bb_hit
  4691                                  %endif
  4692 00000FD8 31D2                    	xor dx, dx		; do not skip WHILE
  4693 00000FDA EB2C                    	jmp short pp13
  4694                                  
  4695                                  pp12:
  4696 00000FDC F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  4697 00000FE1 75EE                    	jnz @B
  4698                                  
  4699 00000FE3 E822FD                  	call traceone
  4700 00000FE6 7242                    	jc pp15
  4701                                  	; jc unexpectedinterrupt
  4702                                  
  4703                                  %if _BREAKPOINTS
  4704 00000FE8 BA0000                  	mov dx, 0		; do not skip WHILE
  4705 00000FEB 7413                    	jz @F
  4706                                  
  4707                                  .bb_hit:
  4708 00000FED E8EDFA                  	call handle_bb_hit_pass_match
  4709 00000FF0 7204                    	jc .actual_hit
  4710                                  d5	call d5message
  4711                                  d5	asciz "in pp12.bb_hit after non-hit",13,10
  4712 00000FF2 741C                    	jz pp13.nodump
  4713 00000FF4 EB12                    	jmp pp13
  4714                                  
  4715                                  
  4716                                  .actual_hit:
  4717                                  %if _PM
  4718                                  	call resetmode
  4719                                  %endif
  4720 00000FF6 E878F3                  	call put_deferred_message_silent
  4721 00000FF9 E87A00                  	call dumpregs_extended_silent
  4722 00000FFC 59                      	pop cx
  4723 00000FFD 5B                      	pop bx			; (discard counter)
  4724 00000FFE EB23                    	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 00001000 813E[0000][0000]        	cmp word [run_int], int1msg
  4738 00001006 7522                    	jne pp15		; if some other interrupt (unexpected) -->
  4739                                  
  4740                                  pp13:
  4741 00001008 52                      	push dx
  4742                                  %if _PM
  4743                                  	call resetmode
  4744                                  %endif
  4745                                  		; An expected breakpoint. Dump registers, then loop.
  4746 00001009 E865F3                  	call put_deferred_message_silent
  4747 0000100C E86700                  	call dumpregs_extended_silent
  4748 0000100F 5A                      	pop dx			; preserve skip WHILE flag
  4749                                  
  4750                                  .nodump:
  4751 00001010 E883FA                  	call tt_handle_while
  4752 00001013 59                      	pop cx
  4753 00001014 5B                      	pop bx
  4754                                  
  4755 00001015 83E901                  	sub cx, 1
  4756 00001018 83DB00                  	sbb bx, 0
  4757                                  
  4758 0000101B 85DB                    	test bx, bx
  4759 0000101D 7508                    	jnz pp14
  4760 0000101F 85C9                    	test cx, cx
  4761 00001021 7504                    	jnz pp14		; back for more -->
  4762                                  
  4763                                  @@:
  4764                                  %if _PM
  4765                                  	call resetmode
  4766                                  %endif
  4767 00001023 E8(0000)                	call silence_dump
  4768                                  
  4769 00001026 C3                      	retn
  4770                                  
  4771                                  %if ($ - pp1 - 1) < 128
  4772                                  pp14: equ pp1
  4773                                  %else
  4774 00001027 E9C9FE                  pp14:	jmp pp1
  4775                                  %endif
  4776                                  
  4777                                  pp15:
  4778 0000102A E99FFC                  	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 0000102D F606[0200]10            	testopt [options6], opt6_rh_mode
  5071 00001032 7507                    	jnz @F
  5072                                  %endif
  5073 00001034 F606[0300]10            	testopt [internalflags], tt_silent_mode
  5074 00001039 743A                    	jz terminate_silent_dump.ret
  5075                                  @@:
  5076 0000103B 06                      	push es
  5077 0000103C 57                      	push di
  5078 0000103D 50                      	push ax
  5079 0000103E 8E06[0000]              	mov es, word [auxbuff_segorsel]
  5080 00001042 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  5081                                  %if _PM
  5082                                  	cmp di, word [auxbuff_switchbuffer_size]
  5083                                  	je terminate_silent_dump.done
  5084                                  %else
  5085 00001046 85FF                    	test di, di
  5086 00001048 7428                    	jz terminate_silent_dump.done
  5087                                  %endif
  5088 0000104A 4F                      	dec di
  5089 0000104B B000                    	mov al, 0
  5090 0000104D AE                      	scasb
  5091 0000104E 7422                    	je terminate_silent_dump.done
  5092 00001050 EB1B                    	jmp @FF
  5093                                  
  5094                                  terminate_silent_dump:
  5095                                  %if _RH
  5096 00001052 F606[0200]10            	testopt [options6], opt6_rh_mode
  5097 00001057 7507                    	jnz @F
  5098                                  %endif
  5099 00001059 F606[0300]10            	testopt [internalflags], tt_silent_mode
  5100 0000105E 7415                    	jz .ret
  5101                                  @@:
  5102                                  .is_silent:
  5103 00001060 06                      	push es
  5104 00001061 57                      	push di
  5105 00001062 50                      	push ax
  5106 00001063 8E06[0000]              	mov es, word [auxbuff_segorsel]
  5107 00001067 8B3E[0000]              	mov di, word [auxbuff_behind_last_silent]
  5108 0000106B B000                    	mov al, 0
  5109                                  @@:
  5110 0000106D AA                      	stosb
  5111 0000106E FF06[0000]              	inc word [auxbuff_behind_last_silent]
  5112                                  				; -> point past the NUL
  5113                                  .done:
  5114 00001072 58                      	pop ax
  5115 00001073 5F                      	pop di
  5116 00001074 07                      	pop es
  5117                                  .ret:
  5118 00001075 C3                      	retn
  5119                                  
  5120                                  
  5121                                  dumpregs_extended_silent:
  5122                                  %if _PM
  5123                                  	call resetmode
  5124                                  %endif
  5125 00001076 E8EFFB                  	call silence_init
  5126                                  		; Call dumpregs (trimputs, puts, putsline, disasm) with
  5127                                  		;  "silence" flag (writes to auxbuff instead of terminal).
  5128 00001079 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 0000107C E8DCFB                  	call silence_exit
  5135                                  %endif	; !_LOADER
  5136                                  
  5137                                  
  5138                                  handle_serial_flags_ctrl_c: section_of_function
  5139 0000107F 1E                      	push ds
  5140 00001080 50                      	push ax
  5141 00001081 16                      	 push ss
  5142 00001082 1F                      	 pop ds
  5143 00001083 F606[0300]40            	testopt [options3], opt3_check_ctrlc_0bh
  5144 00001088 7409                    	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 0000108A E8(0000)                	call InDOS
  5149 0000108D 7504                    	jnz @F
  5150 0000108F B40B                    	mov ah, 0Bh
  5151                                  	doscall			; allow to break with Ctrl-C
  1497 00001091 CD21                <1>  int 21h
  5152                                  @@:
  5153                                  @@:
  5154 00001093 F606[0000]02            	testopt [serial_flags], sf_ctrl_c
  5155 00001098 755B                    	jnz handle_ctrl_c
  5156 0000109A F606[0000]10            	testopt [serial_flags], sf_use_serial
  5157 0000109F 7551                    	jnz .ret
  5158 000010A1 E8(0000)                	call InDOS_or_BIOS_IO
  5159 000010A4 744C                    	jz .ret
  5160 000010A6 F606[0300]20            	testopt [options3], opt3_check_ctrlc_keyb
  5161 000010AB 7445                    	jz .ret
  5162                                  
  5163                                  .check_rombios_buffer:
  5164 000010AD 53                      	push bx
  5165 000010AE 52                      	push dx
  5166 000010AF B84000                  	mov ax, 40h		; dual mode segment/selector
  5167 000010B2 50                      	 push ax
  5168 000010B3 A1[0000]                	mov ax, word [io_end_buffer]
  5169 000010B6 8B16[0000]              	mov dx, word [io_start_buffer]
  5170 000010BA 1F                      	 pop ds
  5171 000010BB 85C0                    	test ax, ax
  5172 000010BD 7503                    	jnz @F
  5173 000010BF A18200                  	mov ax, word [82h]	; end of circular keypress buffer
  5174                                  @@:
  5175 000010C2 85D2                    	test dx, dx
  5176 000010C4 7504                    	jnz @F
  5177 000010C6 8B168000                	mov dx, word [80h]	; start of circular buffer
  5178                                  @@:
  5179 000010CA 89C3                    	mov bx, ax
  5180 000010CC 29D3                    	sub bx, dx		; cmp end, start
  5181 000010CE 7620                    	jbe .ret_dx_bx		; invalid -->
  5182 000010D0 F6C301                  	test bl, 1		; even amount of bytes ?
  5183 000010D3 751B                    	jnz .ret_dx_bx		; invalid -->
  5184 000010D5 8B1E1A00                	mov bx, word [1Ah]	; current head of circular buffer
  5185                                  .loop:
  5186 000010D9 3B1E1C00                	cmp bx, word [1Ch]	; equal to current tail ?
  5187 000010DD 7411                    	je .ret_dx_bx		; yes, all entries checked -->
  5188 000010DF 803F03                  	cmp byte [bx], 3	; is it Ctrl-C ?
  5189 000010E2 7411                    	je handle_ctrl_c	; yes, handle -->
  5190 000010E4 43                      	inc bx
  5191 000010E5 43                      	inc bx			; -> next entry
  5192 000010E6 39C3                    	cmp bx, ax		; at end of buffer ?
  5193 000010E8 72EF                    	jb .loop		; no, loop -->
  5194 000010EA 7704                    	ja .ret_dx_bx		; invalid -->
  5195 000010EC 89D3                    	mov bx, dx		; reset to start of buffer
  5196 000010EE EBE9                    	jmp .loop		; then loop -->
  5197                                  
  5198                                  .ret_dx_bx:
  5199 000010F0 5A                      	pop dx
  5200 000010F1 5B                      	pop bx
  5201                                  
  5202                                  .ret:
  5203 000010F2 58                      	pop ax
  5204 000010F3 1F                      	pop ds
  5205 000010F4 C3                      	retn
  5206                                  
  5207                                  
  5208                                  handle_ctrl_c:
  5209 000010F5 16                      	 push ss
  5210 000010F6 1F                      	 pop ds
  5211 000010F7 16                      	 push ss
  5212 000010F8 07                      	 pop es
  5213                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  5214 000010F9 C606[0000]00            	mov byte [in_getinput], 0
  5215                                  %endif
  5216 000010FE 8026[0000]F9            	clropt [serial_flags], sf_ctrl_c | sf_double_ctrl_c
  5217                                  %if _PM
  5218                                  	call resetmode
  5219                                  %endif
  5220                                  %if !_LOADER
  5221 00001103 E827FF                  	call terminate_silent_dump.if_nonnull
  5222 00001106 E8(0000)                	call silence_dump
  5223                                  %endif
  5224 00001109 BA[0000]                	mov dx, msg.ctrlc
  5225 0000110C E8(0000)                	call putsz
  5226                                  
  5227 0000110F 800E[0000]10            	setopt [internalflags3], dif3_input_terminal_override
  5228                                  				; make sure we drain terminal input
  5229                                  @@:
  5230 00001114 E8(0000)                	call getc_if_any	; drain the buffer
  5231 00001117 75FB                    	jnz @B			; if any was available -->
  5232                                  
  5233 00001119 8026[0000]EF            	clropt [internalflags3], dif3_input_terminal_override
  5234 0000111E 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 00001121 B400                    	mov ah, 0
  5256 00001123 F606[0000]40            	testopt [internalflags2], dif2_tpg_proceed_bp_set
  5257 00001128 7461                    	jz proceed_wp.retn	; (NC)
  5258 0000112A BF0100                  	mov di, 1
  5259 0000112D 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 0000112F E865F4                  	call delay_before_bp
  5278                                  %endif
  5279 00001132 31FF                    	xor di, di
  5280                                  proceed_wp:
  5281                                  	lframe near
  5282 00001134 5589E5                  	lenter
  5283 00001137 83F701                  	xor di, 1
  5284                                  	lvar	word, is_write
  5285 0000113A 57                      	 push di
  5286                                  
  5287 0000113B A1[0000]                	mov ax, word [tpg_proceed_bp]
  5288                                  %if _PM
  5289                                  	mov dx, word [tpg_proceed_bp + 2]
  5290                                  %else
  5291 0000113E 31D2                    	xor dx, dx
  5292 00001140 8A16[0200]              	mov dl, byte [tpg_proceed_bp + 2]
  5293                                  %endif
  5294 00001144 E8B8F7                  	call getsegmented
  5295 00001147 A0[0500]                	mov al, byte [tpg_proceed_bp + BPSIZE - 1]
  5296                                  				; al = byte to restore
  5297 0000114A B402                    	mov ah, 2		; error reason: unreachable
  5298 0000114C 723A                    	jc .return
  5299                                  
  5300 0000114E F646FE01                	test byte [bp + ?is_write], 1
  5301                                  				; (NC) is it writing ?
  5302 00001152 7518                    	jnz .write
  5303                                  .restore:
  5304 00001154 50                      	push ax
  5305 00001155 E8(0000)                	call readmem		; read current byte
  5306 00001158 3CCC                    	cmp al, 0CCh		; is this still what we wrote?
  5307 0000115A B403                    	mov ah, 3		; error reason: overwritten, al = new value
  5308 0000115C F9                      	stc
  5309 0000115D 7529                    	jne .return_discard	; nope --> (CY)
  5310 0000115F 58                      	pop ax
  5311 00001160 E8(0000)                	call writemem		; return the byte to its original value
  5312 00001163 720D                    	jc .next		; failed --> (CY, handled there)
  5313 00001165 C606[0500]CC            	mov byte [tpg_proceed_bp + BPSIZE - 1], 0CCh
  5314                                  				; reset stored point
  5315 0000116A EB06                    	jmp short .next
  5316                                  
  5317                                  .write:
  5318 0000116C E8(0000)                	call writemem
  5319 0000116F A2[0500]                	mov byte [tpg_proceed_bp + BPSIZE - 1], al
  5320                                  				; save the previous byte there
  5321                                  .next:
  5322 00001172 B401                    	mov ah, 1		; (in case of error) error reason: cannot write
  5323 00001174 7212                    	jc .return		; failed to write --> (CY)
  5324 00001176 B400                    	mov ah, 0		; (no error)
  5325                                  
  5326 00001178 800E[0000]40                    setopt [internalflags2], dif2_tpg_proceed_bp_set
  5327                                  				; set flag in case of successful writing
  5328 0000117D F646FE01                	test byte [bp + ?is_write], 1
  5329                                  				; (NC) is it writing ?
  5330 00001181 7505                    	jnz .return		; yes, leave flag set -->
  5331 00001183 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 00001188 89EC5D                  	lleave
  5336                                  .retn:
  5337 0000118B 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                                  	call resetmode
  5358                                  %endif
  5359                                  
  5360 0000118C 50                      	push ax
  5361 0000118D 53                      	push bx
  5362 0000118E 51                      	push cx
  5363 0000118F 56                      	push si
  5364 00001190 E8(0000)                	call silence_dump	; do away with silent mode
  5365 00001193 5E                      	pop si
  5366 00001194 59                      	pop cx
  5367 00001195 5B                      	pop bx
  5368 00001196 58                      	pop ax
  5369                                  
  5370 00001197 800E[0100]08            	setopt [internalflags2], dif2_bp_failure
  5371                                  
  5372                                  	lframe near
  5373                                  	lpar dword, linear
  5374 0000119C 5589E5                  	lenter
  5375                                  	lvar word, input_ax
  5376 0000119F 50                      	 push ax
  5377                                  
  5378 000011A0 BA[0000]                	mov dx, msg.cant_bp_the
  5379 000011A3 E8(0000)                	call putsz
  5380 000011A6 F6C780                  	test bh, 80h
  5381 000011A9 740B                    	jz @F
  5382                                  
  5383 000011AB 89C8                    	mov ax, cx
  5384 000011AD 40                      	inc ax			; make it 1-based
  5385 000011AE E812F6                  	call putordinalbyte
  5386                                  
  5387 000011B1 BA[0000]                	mov dx, msg.cant_bp_type_gg
  5388 000011B4 EB15                    	jmp .got_type
  5389                                  
  5390                                  @@:
  5391 000011B6 F6C740                  	test bh, 40h
  5392 000011B9 740D                    	jz @F
  5393                                  
  5394 000011BB 89C8                    	mov ax, cx
  5395 000011BD BF[0000]                	mov di, msg.cant_bp_type_permanent.index
  5396 000011C0 E8(0000)                	call hexbyte		; (0-based index)
  5397                                  
  5398 000011C3 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 000011C6 EB03                    	jmp .got_type
  5409                                  
  5410                                  @@:
  5411 000011C8 BA[0000]                	mov dx, msg.cant_bp_type_proceed
  5412                                  
  5413                                  .got_type:
  5414 000011CB E8(0000)                	call putsz
  5415                                  
  5416 000011CE BF[0000]                	mov di, msg.cant_bp_linear.address1
  5417 000011D1 8B4606                  	mov ax, word [bp + ?linear + 2]
  5418                                  %ifn _PM
  5419 000011D4 B400                    	mov ah, 0
  5420                                  %endif
  5421 000011D6 E8(0000)                	call hexword
  5422 000011D9 47                      	inc di
  5423                                  	; mov di, msg.cant_bp_linear.address2
  5424 000011DA 8B4604                  	mov ax, word [bp + ?linear]
  5425 000011DD E8(0000)                	call hexword
  5426                                  
  5427 000011E0 BA[0000]                	mov dx, msg.cant_bp_linear
  5428 000011E3 E8(0000)                	call putsz
  5429                                  
  5430 000011E6 BF[0000]                	mov di, msg.cant_bp_restore.value
  5431 000011E9 89D8                    	mov ax, bx
  5432 000011EB E8(0000)                	call hexbyte
  5433                                  
  5434 000011EE BA[0000]                	mov dx, msg.cant_bp_write
  5435 000011F1 8B46FE                  	mov ax, word [bp + ?input_ax]
  5436 000011F4 F6C480                  	test ah, 80h
  5437 000011F7 7406                    	jz @F
  5438 000011F9 80E47F                  	and ah, ~80h
  5439 000011FC BA[0000]                	mov dx, msg.cant_bp_restore
  5440                                  @@:
  5441 000011FF E8(0000)                	call putsz
  5442                                  
  5443 00001202 BF[0000]                	mov di, msg.cant_bp_reason3.value
  5444 00001205 E8(0000)                	call hexbyte
  5445                                  
  5446 00001208 BA[0000]                	mov dx, msg.cant_bp_reason
  5447 0000120B E8(0000)                	call putsz
  5448                                  
  5449 0000120E BA[0000]                	mov dx, msg.cant_bp_reason0
  5450 00001211 80FC01                  	cmp ah, 1
  5451 00001214 7215                    	jb @F
  5452 00001216 BA[0000]                	mov dx, msg.cant_bp_reason1
  5453 00001219 7410                    	je @F
  5454 0000121B BA[0000]                	mov dx, msg.cant_bp_reason2
  5455 0000121E 80FC03                  	cmp ah, 3
  5456 00001221 7208                    	jb @F
  5457 00001223 BA[0000]                	mov dx, msg.cant_bp_reason3
  5458 00001226 7403                    	je @F
  5459 00001228 BA[0000]                	mov dx, msg.cant_bp_reasonu
  5460                                  @@:
  5461 0000122B E8(0000)                	call putsz
  5462                                  
  5463 0000122E 89EC5D                  	lleave
  5464 00001231 C20400                  	lret
  5465                                  
  5466                                  
  5467                                  %if _PM
  5468                                  isdpmientry:
  5469                                  	testopt [internalflags4], dif4_int_2F_hooked
  5470                                  	jnz .stdhook
  5471                                  	mov word [reg_eip], mydpmientry
  5472                                  	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                                  	mov bx, word [reg_esp]
  5477                                  	push ds
  5478                                  	mov ds, word [reg_ss]	; ds:bx-> (16-bit) stack
  5479                                  	mov si, word [bx+0]
  5480                                  	mov bx, word [bx+2]	; get (16-bit) far return address
  5481                                  	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 00001234 F606[0000]80            	testopt [internalflags2], dif2_tpg_keep_proceed_bp
  5519 00001239 750C                    	jnz @F
  5520                                  
  5521                                  	_386_PM_o32		; mov edx, esi
  5522 0000123B 89F2                    	mov dx, si		; bx:(e)dx = segmented
  5523 0000123D E82DF6                  	call getlinear_d_b	; dx:ax = linear
  5524                                  
  5525 00001240 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 00001243 8916[0200]              	mov word [tpg_proceed_bp + 2], dx
  5530                                  				; store in point
  5531                                  @@:
  5532 00001247 C606[0500]CC            	mov byte [tpg_proceed_bp + BPSIZE - 1], 0CCh
  5533                                  				; initialise content
  5534 0000124C E8E0FE                  	call proceed_writepoint
  5535                                  		; This call might return modeswitched.
  5536 0000124F 7308                    	jnc @F
  5537                                  
  5538 00001251 80E47F                  	and ah, ~80h		; mark error during writing
  5539                                  
  5540 00001254 31C9                    	xor cx, cx		; cx = 0 in case of branching
  5541 00001256 51                      	push cx			; put the zero on the stack
  5542                                  
  5543 00001257 EB0E                    	jmp .failure
  5544                                  
  5545                                  @@:
  5546                                  		; The run functions call resetmode.
  5547                                  %if _BREAKPOINTS
  5548 00001259 E87400                  	call run_with_bb
  5549 0000125C 89C8                    	mov ax, cx
  5550                                  %else
  5551                                  	call run
  5552                                  	xor ax, ax
  5553                                  %endif
  5554 0000125E 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 0000125F E8BFFE                  	call proceed_writepoint_restore
  5564                                  		; This call might return modeswitched.
  5565 00001262 7326                    	jnc @F
  5566                                  
  5567 00001264 80CC80                  	or ah, 80h		; mark error during restoration
  5568                                  
  5569                                  .failure:
  5570                                  		; Here we may be modeswitched.
  5571 00001267 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  5572                                  				; is it from gg ?
  5573 0000126C 7559                    	jnz .return_CY_pop_cx	; (CY) yes, return to gg
  5574                                  		; This branch may be taken while modeswitched.
  5575                                  
  5576                                  %if _PM
  5577                                  	call resetmode
  5578                                  %endif
  5579                                  
  5580 0000126E E800F1                  	call put_deferred_message_silent
  5581                                  
  5582 00001271 50                      	push ax
  5583 00001272 E8(0000)                	call silence_dump
  5584 00001275 58                      	pop ax
  5585                                  
  5586 00001276 FF36[0200]              	 push word [tpg_proceed_bp + 2]
  5587 0000127A FF36[0000]              	 push word [tpg_proceed_bp]
  5588 0000127E 8A1E[0500]              	mov bl, [tpg_proceed_bp + BPSIZE - 1]
  5589 00001282 B700                    	mov bh, 0
  5590 00001284 E805FF                  	call display_breakpoint_failure
  5591                                  		; This function calls resetmode.
  5592 00001287 E9(0000)                	jmp cmd3
  5593                                  
  5594                                  @@:
  5595 0000128A E852F6                  	call get_cseip_of_possible_breakpoint
  5596                                  				; dx:ax = linear address 1 before cs:(e)ip
  5597 0000128D 7236                    	jc .return_CY_pop_cx_ax_zero
  5598                                  
  5599 0000128F 59                      	pop cx
  5600                                  %if _PM
  5601                                  	cmp word [tpg_proceed_bp + 2], dx
  5602                                  %else
  5603 00001290 84F6                    	test dh, dh		; (bits 24 to 31 set. shouldn't happen)
  5604 00001292 7517                    	jnz .not_pp
  5605 00001294 3816[0200]              	cmp byte [tpg_proceed_bp + 2], dl
  5606                                  %endif
  5607 00001298 7511                    	jne .not_pp
  5608 0000129A 3906[0000]              	cmp word [tpg_proceed_bp], ax
  5609 0000129E 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 000012A0 813E[0000][0000]        	cmp word [run_int], int3msg
  5614 000012A6 7503                    	jne .not_pp		; is unexpected (not returned by interrupt 03h) -->
  5615 000012A8 80C908                  	or cl, 8		; set flag: pp hit
  5616                                  
  5617                                  .not_pp:
  5618 000012AB B400                    	mov ah, 0		; set error to "no error"
  5619                                  
  5620 000012AD E319                    	jcxz .return_CY		; bb hit/pass/nonpass or pp hit ?  if no -->
  5621                                  
  5622 000012AF E8E1F0                  	call adjust_cseip_after_breakpoint
  5623                                  				; decrement (e)ip to point at the instruction
  5624                                  
  5625 000012B2 F6C101                  	test cl, 1		; bb hit ?
  5626 000012B5 750A                    	jnz .return		; yes, return (NC, NZ) -->
  5627                                  
  5628 000012B7 F6C108                  	test cl, 8		; proceed point matched ?
  5629 000012BA 7506                    	jnz @F			; yes -->
  5630                                  
  5631 000012BC 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 000012C1 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 000012C2 31C0                    	xor ax, ax		; ah = 0 (NC, ZR)
  5642 000012C4 C3                      	retn
  5643                                  
  5644                                  		; set ax = 0, pop cx, CY
  5645                                  .return_CY_pop_cx_ax_zero:
  5646 000012C5 31C0                    	xor ax, ax
  5647                                  
  5648                                  		; pop cx, CY (preserve ax)
  5649                                  .return_CY_pop_cx:
  5650 000012C7 59                      	pop cx
  5651                                  .return_CY:
  5652 000012C8 F9                      	stc
  5653 000012C9 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                                  	call resetmode_and_test_d_b_bit
  5663                                  %endif
  5664 000012CA 1E                      	push ds
  5665 000012CB 8EDB                    	mov ds, bx
  5666                                  %if _PM
  5667                                  	jz .16
  5668                                  	a32			; use esi for lodsb
  5669                                  .16:
  5670                                  %endif
  5671 000012CD AC                      	lodsb
  5672 000012CE 1F                      	pop ds
  5673 000012CF 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 000012D0 F606[0000]08            	testopt [internalflags2], dif2_gg_is_gg
  5690 000012D5 750C                    	jnz .no_bb
  5691                                  
  5692 000012D7 F606[0300]C0            	testopt [internalflags], tt_no_bb | tt_no_bb_first
  5693 000012DC 740C                    	jz @F
  5694                                  
  5695 000012DE 8026[0300]7F            	clropt [internalflags], tt_no_bb_first
  5696                                  
  5697                                  .no_bb:
  5698 000012E3 E87400                  	call run
  5699 000012E6 31C9                    	xor cx, cx
  5700 000012E8 F9                      	stc
  5701 000012E9 C3                      	retn
  5702                                  
  5703                                  @@:
  5704                                  .gg5:
  5705                                  %if _BREAKPOINTS
  5706 000012EA E8DAF2                  	call bb_writepoints_init_reset
  5707                                  %endif
  5708                                  
  5709 000012ED F606[0000]10            	testopt [internalflags2], dif2_gg_first_detected
  5710 000012F2 7436                    	jz .only_run		; easy case, no cseip point detected -->
  5711                                  
  5712                                  
  5713                                  		; Enter special mode: Restore cseip breakpoint content.
  5714 000012F4 800E[0000]02            	setopt [internalflags2], dif2_gg_skip_non_cseip
  5715                                  
  5716 000012F9 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5717 000012FC 89E5                    	mov bp, sp		; -> error info
  5718                                  
  5719 000012FE B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5720                                  				; = index above last one to restore
  5721 00001301 E891F3                  	call bb_restorepoints_and_init_error_info
  5722 00001304 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 00001306 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
  5728                                  
  5729                                  		; Enter special mode: Skip cseip breakpoints.
  5730 0000130B 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 00001310 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5735 00001313 E882F3                  	call bb_restorepoints
  5736                                  
  5737                                  		; Exit special mode: No longer skip cseip breakpoints.
  5738 00001316 8026[0000]FB            	clropt [internalflags2], dif2_gg_skip_cseip
  5739                                  
  5740                                  		; The failure that led us here is already noted in the info.
  5741 0000131B EB1D                    	jmp .bb_exit
  5742                                  
  5743                                  
  5744                                  @@:
  5745                                  		; Success! Now discard the reserved error info.
  5746 0000131D 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5747                                  
  5748                                  		; Exit special mode, do not skip non-cseip breakpoints anymore.
  5749 00001320 8026[0000]FD            	clropt [internalflags2], dif2_gg_skip_non_cseip
  5750                                  
  5751                                  		; Enter special mode: Skip matching/restoring cseip breakpoint.
  5752 00001325 800E[0000]04            	setopt [internalflags2], dif2_gg_skip_cseip
  5753                                  
  5754                                  .only_run:
  5755 0000132A E82D00                  	call run
  5756                                  .after_run:
  5757                                  
  5758                                  %if _BREAKPOINTS
  5759 0000132D 83EC20                  	sub sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5760 00001330 89E5                    	mov bp, sp
  5761                                  
  5762 00001332 B91000                  	mov cx, _NUM_B_BP + _NUM_SYM_BP
  5763                                  				; = index above last one to restore
  5764 00001335 E85DF3                  	call bb_restorepoints_and_init_error_info
  5765 00001338 7308                    	jnc @F
  5766                                  
  5767                                  .bb_exit:
  5768 0000133A B8FFFF                  	mov ax, -1
  5769 0000133D 50                      	push ax			; (unused: ax error info)
  5770 0000133E 50                      	push ax			; cx error point index, -1 = invalid
  5771                                  
  5772 0000133F E9A2F2                  	jmp bb_restorepoints_exit
  5773                                  
  5774                                  
  5775                                  @@:
  5776 00001342 83C420                  	add sp, (_NUM_B_BP + _NUM_SYM_BP) * 2
  5777                                  
  5778 00001345 E85CF0                  	call bb_check_hit
  5779 00001348 89C1                    	mov cx, ax
  5780 0000134A 9C                      	pushf
  5781                                  		; Clear all special modes. Stop specialcasing cseip breakpoint.
  5782                                  		;
  5783                                  		; This resets all the special flags for subsequent calls.
  5784 0000134B 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  5787 00001350 9D                      	popf			; CF
  5788 00001351 7302                    	jnc @F
  5789                                  
  5790 00001353 F9                      	stc
  5791                                  				; cx = flags as returned by bb_check_hit
  5792 00001354 C3                      	retn
  5793                                  
  5794                                  @@:
  5795 00001355 E83BF0                  	call adjust_cseip_after_breakpoint
  5796                                  				; re-execute (restored) opcode one byte in front of this
  5797 00001358 F8                      	clc			; (NC)
  5798                                  				; cx = flags as returned by bb_check_hit
  5799 00001359 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 0000135A 16                      	 push ss
  5822 0000135B 07                      	 pop es
  5823                                  %if _PM
  5824                                  	call resetmode
  5825                                  	call remember_mode
  5826                                  %endif
  5827                                  %if _DELAY_BEFORE_BP
  5828 0000135C 8026[0200]7F            	clropt [internalflags3], dif3_delayed
  5829                                  %endif
  5830                                  %if !_LOADER
  5831 00001361 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 00001367 E84A03                  	call seteq			; set CS:IP to '=' address
  5836                                  %endif
  5837                                  
  5838                                  %if _VXCHG
  5839 0000136A B000                    	mov al, 0			; restore debuggee screen
  5840 0000136C E8(0000)                	call swapscreen
  5841                                  %endif
  5842                                  
  5843                                  %if _ALTVID
  5844 0000136F E84501                  	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                                  	mov es, word [reg_ds]
  5865                                  	mov es, word [reg_ss]
  5866                                  _386	mov es, word [reg_fs]
  5867                                  _386	mov es, word [reg_gs]
  5868                                  %endif
  5869 00001372 8E06[0000]              	mov es, word [reg_es]		; last one: actual es value
  5870                                  
  5871                                  %if !_LOADER
  5872 00001376 8B1E[0000]              	mov bx, word [pspdbe]
  5873 0000137A E8(0000)                	call setpsp			; set debuggee's PSP
  5874 0000137D 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 00001380 A9                      	db __TEST_IMM16
  5881 00001381 6100                    	dw __REL16__(.skipints)
  5882                                   %endif
  5883                                   %if _DEBUG_COND
  5884 00001383 F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  5885 00001388 745A                    	jz .skipints
  5886 0000138A E80200                  	call set_interrupts
  5887 0000138D EB55                    	jmp .skipints
  5888                                  
  5889                                  set_interrupts: equ $
  5890                                   %endif
  5891 0000138F 51                      	push cx
  5892 00001390 56                      	push si
  5893 00001391 50                      	push ax
  5894 00001392 52                      	push dx
  5895 00001393 06                      	push es
  5896 00001394 53                      	push bx
  5897 00001395 55                      	push bp
  5898 00001396 57                      	push di
  5899                                  
  5900                                  %if _PM
  5901                                  	call ispm
  5902                                  	jz @F			; in PM -->
  5903                                  	testopt [internalflags], canswitchmode
  5904                                  	jz @FF			; in 86 Mode and cannot switch to PM -->
  5905                                  
  5906                                  d4	call d4message
  5907                                  d4	asciz "In run (switch mode before calling pm_set_handlers)",13,10
  5908                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  5909                                  	mov al, 0
  5910                                  	call sr_state		; save state
  5911                                  	call switchmode 	; switch to PM
  5912                                  		; ! handle_mode_changed not called here !
  5913                                  		; do not call InDOS or other functions using seg/sels
  5914                                  @@:
  5915                                  	call pm_set_handlers
  5916                                  		; ! this calls resetmode
  5917                                  @@:
  5918                                  %endif
  5919                                  
  5920                                  %if _CATCHINT06 && _DETECT95LX
  5921 00001397 8B0E[0000]              	mov cx, word [inttab_number_variable]
  5922                                  %else
  5923                                  	mov cx, inttab_number
  5924                                  %endif
  5925 0000139B E33E                    	jcxz .intend
  5926 0000139D BE[0000]                	mov si, inttab
  5927                                  .intloop:
  5928 000013A0 AC                      	lodsb
  5929 000013A1 92                      	xchg ax, dx
  5930 000013A2 AD                      	lodsw				; get address
  5931 000013A3 92                      	xchg ax, dx
  5932                                  %if _DEBUGUPDATESAVE
  5933 000013A4 89D7                    	mov di, dx			; -> IISP header
  5934                                  %endif
  5935                                  
  5936 000013A6 E8(0000)                	call InDOS
  5937 000013A9 7420                    	jz .int21_25
  5938                                  
  5939 000013AB 31DB                    	xor bx, bx
  5940                                  %if _PM
  5941                                  	call ispm
  5942                                  	jnz @F
  5943                                  	push dx
  5944                                  	mov dx, bx			; set segment to access (= 0)
  5945                                  	call setrmsegm			; get bx = selector configured to this
  5946                                  	pop dx
  5947                                  @@:
  5948                                  %endif
  5949 000013AD 8EC3                    	mov es, bx			; => 86 Mode IVT (segment or selector)
  5950                                  %if _PM
  5951                                  	xor bx, bx			; bh = 0
  5952                                  %endif
  5953 000013AF 88C3                    	mov bl, al
  5954 000013B1 01DB                    	add bx, bx
  5955 000013B3 01DB                    	add bx, bx
  5956                                  
  5957                                  %if _DEBUGUPDATESAVE
  5958 000013B5 26FF7702                	push word [ es:bx + 2 ]
  5959 000013B9 26FF37                  	push word [ es:bx ]		; get vector
  5960 000013BC 8F4502                  	pop word [ di + ieNext ]
  5961 000013BF 8F4504                  	pop word [ di + ieNext + 2]
  5962                                  %endif
  5963                                  
  5964 000013C2 268917                  	mov word [ es:bx ], dx
  5965                                  %if _PM
  5966                                  	push word [ pspdbg ]		; => lDEBUG_DATA_ENTRY (86 Mode seg)
  5967                                  	pop word [ es:bx + 2 ]
  5968                                  %else
  5969 000013C5 268C5F02                	mov word [ es:bx + 2 ], ds	; => lDEBUG_DATA_ENTRY
  5970                                  %endif
  5971 000013C9 EB0E                    	jmp short .intset
  5972                                  
  5973                                  .int21_25:
  5974                                  
  5975                                  %if _PM
  5976                                   %if _DEBUGUPDATESAVE
  5977                                  	mov ah, 35h			; get interrupt vector
  5978                                  	 push word [pspdbg]		; => lDEBUG_DATA_ENTRY
  5979                                  	dual2call _doscall_return_es_parameter_es_ds
  5980                                  	mov word [ di + ieNext ], bx
  5981                                  	 pop word [ di + ieNext + 2 ]
  5982                                   %endif
  5983                                  	mov ah, 25h			; set interrupt vector
  5984                                  	push word [pspdbg]		; => lDEBUG_DATA_ENTRY
  5985                                  	dual2call _doscall_return_es_parameter_es_ds
  5986                                  	pop ax				; (discard returned parameter)
  5987                                  %else
  5988                                   %if _DEBUGUPDATESAVE
  5989 000013CB B435                    	mov ah, 35h
  5990 000013CD CD21                    	int 21h				; get vector
  5991 000013CF 895D02                  	mov word [ di + ieNext ], bx
  5992 000013D2 8C4504                  	mov word [ di + ieNext + 2 ], es
  5993                                   %endif
  5994 000013D5 B425                    	mov ah, 25h			; set interrupt vector
  5995 000013D7 CD21                    	int 21h				; ds => lDEBUG_DATA_ENTRY
  5996                                  %endif
  5997                                  .intset:
  5998 000013D9 E2C5                    	loop .intloop
  5999                                  
  6000                                  .intend:
  6001 000013DB 5F                      	pop di
  6002 000013DC 5D                      	pop bp
  6003 000013DD 5B                      	pop bx
  6004 000013DE 07                      	pop es
  6005 000013DF 5A                      	pop dx
  6006 000013E0 58                      	pop ax
  6007 000013E1 5E                      	pop si
  6008 000013E2 59                      	pop cx
  6009                                   %if _DEBUG_COND
  6010 000013E3 C3                      	retn
  6011                                   %endif
  6012                                  .skipints:
  6013                                  %endif
  6014                                  
  6015                                  .2:
  6016                                  %if _RUN2_ENTRY_SECTION
  6017                                   %if _PM
  6018                                  	call ispm
  6019                                  	jnz @F
  6020                                  	push word [cssel]
  6021                                  	db __TEST_IMM8			; (skip push)
  6022                                  @@:
  6023                                   %endif
  6024 000013E4 16                      	push ss
  6025 000013E5 B8[B400]                	mov ax, .entry
  6026 000013E8 50                      	push ax
  6027 000013E9 CB                      	retf
  6028                                  
  6029                                  	usesection lDEBUG_DATA_ENTRY
  6029          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6030                                  .entry:
  6031                                  %endif
  6032 000000B4 2B26[0000]              	sub sp, word [run_sp_reserve]
  6033 000000B8 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                                  	mov ax, word [pspdbg]
  6052                                   %else
  6053 000000BC 8CD0                    	mov ax, ss
  6054                                   %endif
  6055 000000BE 3B063000                	cmp ax, word [SPSAV + 2]
  6056 000000C2 7508                    	jne @F
  6057                                  %endif
  6058 000000C4 2B26[0000]              	sub sp, word [spadjust]
  6059 000000C8 89262E00                	mov word [SPSAV], sp
  6060                                  @@:
  6061                                  %endif
  6062 000000CC FA                      	cli
  6063                                  
  6064 000000CD BC[0000]                	mov sp, regs
  6065                                  %ifn _ONLY386
  6066 000000D0 EB11                    	_386_jmps .386			; -->
  6067 000000D2 58                      	pop ax
  6068 000000D3 58                      	pop ax				; discard all high words
  6069 000000D4 5B                      	pop bx
  6070 000000D5 58                      	pop ax
  6071 000000D6 59                      	pop cx
  6072 000000D7 58                      	pop ax
  6073 000000D8 5A                      	pop dx
  6074 000000D9 58                      	pop ax
  6075 000000DA 58                      	pop ax				; we'll get esp later
  6076 000000DB 58                      	pop ax
  6077 000000DC 5D                      	pop bp
  6078 000000DD 58                      	pop ax
  6079 000000DE 5E                      	pop si
  6080 000000DF 58                      	pop ax
  6081 000000E0 5F                      	pop di
  6082                                  		; ds, ss, cs loaded later
  6083                                  		; es already loaded
  6084                                  %endif
  6085                                  %ifn _ONLYNON386
  6086                                   %ifn _ONLY386
  6087 000000E1 EB18                    	jmp short .common
  6088                                   %endif
  6089                                  
  6090                                  .386:
  6091                                  [cpu 386]
  6092 000000E3 6658                    	pop eax
  6093 000000E5 665B                    	pop ebx
  6094 000000E7 6659                    	pop ecx
  6095 000000E9 665A                    	pop edx
  6096 000000EB 58                      	pop ax
  6097 000000EC 58                      	pop ax				; we'll get esp later
  6098 000000ED 665D                    	pop ebp
  6099 000000EF 665E                    	pop esi
  6100 000000F1 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 000000F3 83C410                  	add sp, byte 8 * 2
  6110 000000F6 0FA1                    	pop fs
  6111 000000F8 58                      	pop ax
  6112 000000F9 0FA9                    	pop gs
  6113                                  __CPU__
  6114                                  .common:
  6115                                  %endif
  6116 000000FB A1[0000]                	mov ax, word [reg_eax]		; restore ax (used to discard words)
  6117 000000FE 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 00000102 66                      	o32			; mov esp, dword [reg_esp]
  6123 00000103 8B26[0000]              	mov sp, word [reg_esp]		; restore program stack
  6124                                  %endif
  6125 00000107 C606[0000]00            	mov byte [bInDbg], 0
  6126                                  
  6127                                  	align 4, nop
  6128                                  patcharea_run:
  6129 0000010C 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 0000012C 66                      	_386_o32		; push dword [reg_efl]
  6139 0000012D FF36[0000]              	push word [reg_efl]
  6140 00000131 66                      	_386_o32		; push dword [reg_cs]	; high word is zero
  6141 00000132 FF36[0000]              	push word [reg_cs]
  6142 00000136 66                      	_386_o32		; push dword [reg_eip]
  6143 00000137 FF36[0000]              	push word [reg_eip]
  6144 0000013B F606[0100]02            	test byte [reg_efl+1], 2	; IF set?
  6145 00000140 8E1E[0000]              	mov ds, word [reg_ds]		; restore ds
  6146 00000144 7401                    	jz .di
  6147 00000146 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 00000147 66                      	o32			; iretd
  6154 00000148 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 00000149 CBEB10FFFFFFFF4B42-     iispentry intr8, 0
  6205 00000152 00EBF400<rep 7h>   
  6206                                  intr8_original: equ intr8.next
  6207 0000015C 9C                      	pushf
  6208 0000015D 2EFF1E[4C01]            	call far [cs:intr8_original]
  6209 00000162 9C                      	pushf
  6210 00000163 53                      	push bx
  6211 00000164 1E                      	push ds
  6212                                  
  6213 00000165 0E                      	 push cs
  6214 00000166 1F                      	 pop ds
  6215                                  
  6216 00000167 803E[0000]00            	cmp byte [bInDbg], 0		; in debugger ?
  6217 0000016C 7559                    	jne .reset			; yes -->
  6218                                  
  6219 0000016E F606[0000]04            	testopt [serial_flags], sf_double_ctrl_c
  6220 00000173 7408                    	jz @F
  6221                                  
  6222 00000175 C706[0000][0000]        	mov word [run_int], runint_ctrlc_msg
  6223 0000017B EB44                    	jmp @FF
  6224                                  
  6225                                  @@:
  6226 0000017D BB4000                  	mov bx, 40h
  6227 00000180 8EDB                    	mov ds, bx
  6228 00000182 F606170004              	test byte [17h], 4		; CTRL currently pressed ?
  6229 00000187 0E                      	 push cs
  6230 00000188 1F                      	 pop ds
  6231 00000189 743C                    	jz .reset			; no -->
  6232                                  
  6233 0000018B 8B1E[0000]              	mov bx, word [intr8_limit]
  6234 0000018F 85DB                    	test bx, bx			; enabled ?
  6235 00000191 7439                    	jz .return			; no -->
  6236 00000193 FF06[0000]              	inc word [intr8_counter]
  6237 00000197 391E[0000]              	cmp word [intr8_counter], bx	; default is ca 5 seconds
  6238 0000019B 722F                    	jb .return
  6239                                  
  6240 0000019D C706[0000][0000]        	mov word [run_int], int8msg
  6241 000001A3 F606[0100]80            	testopt [options], int8_disable_serial
  6242 000001A8 7417                    	jz @F
  6243 000001AA F606[0000]10            	testopt [serial_flags], sf_use_serial
  6244 000001AF 7410                    	jz @F
  6245                                  
  6246                                  		; Immediately disable use of serial I/O.
  6247 000001B1 8026[0000]EF            	clropt [serial_flags], sf_use_serial
  6248 000001B6 8026[0100]BF            	clropt [options], enable_serial
  6249 000001BB C706[0000][0000]        	mov word [run_int], int8_kbd_msg
  6250                                  
  6251                                  @@:
  6252 000001C1 1F                      	pop ds
  6253 000001C2 5B                      	pop bx
  6254 000001C3 9D                      	popf				; (in 86 Mode)
  6255 000001C4 E97B01                  	jmp intrtn
  6256                                  
  6257                                  .reset:
  6258 000001C7 8326[0000]00            	and word [intr8_counter], 0
  6259                                  .return:
  6260 000001CC 1F                      	pop ds
  6261 000001CD 5B                      	pop bx
  6262 000001CE 9D                      	popf				; (in 86 Mode)
  6263 000001CF CF                      	iret
  6264                                  %endif
  6265                                  
  6266                                  
  6267                                  %if !_LOADER
  6268                                  		; Interrupt 22h (program termination) handler.
  6269                                  int22:
  6270 000001D0 FA                      	cli
  6271                                  .cleartraceflag:
  6272 000001D1 0E                      	push cs
  6273 000001D2 1F                      	pop ds
  6274 000001D3 0E                      	push cs
  6275 000001D4 17                      	pop ss
  6276 000001D5 8B26[0000]              	mov sp, word [run_sp]	; restore running stack
  6277 000001D9 0326[0000]              	add sp, word [run_sp_reserve]
  6278 000001DD C706[0000][0000]        	mov word [run_int], progtrm	; set interrupt message
  6279 000001E3 C706[0000][0000]        	mov word [lastcmd], dmycmd	; disable T/P/G auto-repeat
  6280                                  %if _PM
  6281                                  	mov byte [pm_2_86m_0], 0
  6282                                  	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 000001E9 E9FA01                  	jmp intrtn1_entry
  6291                                  %endif
  6292                                  %endif	; !_LOADER
  6293                                  
  6294                                  sharedentry1.hwreset:
  6295 000001EC CB                      	retf
  6296                                  
  6297                                  
  6298                                  %if !_LOADER
  6299 000001ED 90                      	align 2
  6300 000001EE 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 000001F0 EB10FFFFFFFF4B4200-     iispentry intr1, 0, sharedentry1
  6305 000001F9 EBF100<rep 7h>     
  6306                                  	lframe int
  6307 00000202 5589E5                  	lenter
  6308 00000205 50                      	push ax
  6309                                  
  6310                                  %ifn _PASSTF
  6311 00000206 806607FE                	clropt [bp + ?frame_fl], 100h	; clear TF (always)
  6312                                  %endif
  6313                                  
  6314 0000020A 8CC8                    	mov ax, cs
  6315 0000020C 394604                  	cmp word [bp + ?frame_cs], ax	; entry segment ?
  6316 0000020F 751A                    	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 00000211 817E02[3A02]            	cmp word [bp + ?frame_ip], intr0
  6326 00000216 7413                    	je .if_ZR			; that one --> (ZR)
  6327 00000218 817E02[5602]            	cmp word [bp + ?frame_ip], intr3
  6328 0000021D 740C                    	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                                  	cmp word [bp + ?frame_ip], getline_extra_int22.cleartraceflag
  6338                                  	je .if_ZR			; that one --> (ZR)
  6339                                  %endif
  6340 0000021F 817E02[D101]            	cmp word [bp + ?frame_ip], int22.cleartraceflag
  6341 00000224 7405                    	je .if_ZR			; that one --> (ZR)
  6342 00000226 817E02[0000]            	cmp word [bp + ?frame_ip], debug22.cleartraceflag
  6343                                  .if_ZR:
  6344 0000022B 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 0000022C 5D                      	lleave , optimiserestoresp	; restore bp (common before branch)
  6356 0000022D 7501                    	jnz @F				; handle trace entry -->
  6357 0000022F CF                      	iret				; continue run if matched
  6358                                  
  6359                                  @@:
  6360                                  %endif
  6361                                  
  6362 00000230 2EC706[0000][0000]      	mov word [cs:run_int], int1msg	; remember interrupt type
  6363 00000237 E90801                  	jmp intrtn			; jump to register saving routine
  6364                                  
  6365                                  
  6366                                  		; Interrupt 00h (divide error) handler.
  6367 0000023A EB10FFFFFFFF4B4200-     iispentry intr0, 0, sharedentry1
  6367 00000243 EBA700<rep 7h>     
  6368 0000024C 2EC706[0000][0000]      	mov word [cs:run_int], int0msg	; remember interrupt type
  6369 00000253 E9EC00                  	jmp intrtn			; jump to register saving routine
  6370                                  
  6371                                  
  6372                                  
  6373                                  		; Interrupt 03h (breakpoint interrupt) handler.
  6374 00000256 EB10FFFFFFFF4B4200-     iispentry intr3, 0, sharedentry1
  6374 0000025F EB8B00<rep 7h>     
  6375 00000268 2EC706[0000][0000]      	mov word [cs:run_int], int3msg	; remember interrupt type
  6376                                  %if _CATCHINT06
  6377 0000026F E9D000                  	jmp intrtn			; jump to register saving routine
  6378                                  
  6379                                  
  6380                                  		; Interrupt 06h (invalid opcode) handler.
  6381 00000272 EB10FFFFFFFF4B4200-     iispentry intr6, 0, sharedentry2
  6381 0000027B EB1100<rep 7h>     
  6382 00000284 2EC706[0000][0000]      	mov word [cs:run_int], int6msg	; remember interrupt type
  6383                                  %endif
  6384 0000028B E9B400                  	jmp intrtn			; jump to register saving routine
  6385                                  %endif	; !_LOADER
  6386                                  
  6387                                  
  6388                                  sharedentry2.hwreset:
  6389 0000028E 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 0000028F 90EB10FFFFFFFF4B42-     iispentry intr0C, 0, sharedentry2
  6403 00000298 00EBF300<rep 7h>   
  6404                                   %if _MCLOPT
  6405                                  	cmp byte [cs:master_pic_base], 20h
  6406                                  	jae @F
  6407                                   %endif
  6408 000002A2 50                      	push ax
  6409 000002A3 B00B                    	mov al, 0Bh			; request In-Service Register (ISR)
  6410 000002A5 E620                    	out 20h, al			; from primary PIC
  6411 000002A7 E420                    	in al, 20h			; read the ISR
  6412 000002A9 A810                    	test al, 1_0000b		; IRQ #4 occurred ?
  6413 000002AB 58                      	pop ax
  6414 000002AC 7515                    	jnz .notours			; yes, (likely) not a stack fault -->
  6415                                  @@:
  6416 000002AE 2EC706[0000][0000]      	mov word [cs:run_int], int0Cmsg	; remember interrupt type
  6417 000002B5 2E803E[0000]00          	cmp byte [cs:bInDbg], 0
  6418 000002BB 7403E942FD              	jne r86m_debugger_exception
  6419 000002C0 E97F00                  	jmp intrtn			; jump to register saving routine
  6420                                  
  6421                                  .notours:
  6422 000002C3 2EFF2E[9202]            	jmp far [cs:.next]
  6423                                  %endif
  6424                                  %if _CATCHINT0D
  6425                                  
  6426                                  
  6427                                  		; Interrupt 0Dh (general protection fault in R86M, or IRQ) handler.
  6428 000002C8 EB10FFFFFFFF4B4200-     iispentry intr0D, 0, sharedentry2
  6428 000002D1 EBBB00<rep 7h>     
  6429                                   %if _MCLOPT
  6430                                  	cmp byte [cs:master_pic_base], 20h
  6431                                  	jae @F
  6432                                   %endif
  6433 000002DA 50                      	push ax
  6434 000002DB B00B                    	mov al, 0Bh			; request In-Service Register (ISR)
  6435 000002DD E620                    	out 20h, al			; from primary PIC
  6436 000002DF E420                    	in al, 20h			; read the ISR
  6437 000002E1 A820                    	test al, 10_0000b		; IRQ #5 occurred ?
  6438 000002E3 58                      	pop ax
  6439 000002E4 7514                    	jnz .notours			; yes, (likely) not a GPF -->
  6440                                  @@:
  6441 000002E6 2EC706[0000][0000]      	mov word [cs:run_int], int0Dmsg	; remember interrupt type
  6442 000002ED 2E803E[0000]00          	cmp byte [cs:bInDbg], 0
  6443 000002F3 7403E90AFD              	jne r86m_debugger_exception
  6444 000002F8 EB48                    	jmp intrtn			; jump to register saving routine
  6445                                  
  6446                                  .notours:
  6447 000002FA 2EFF2E[CA02]            	jmp far [cs:.next]
  6448                                  %endif
  6449                                  %if _CATCHINT18
  6450                                  		; Interrupt 18h (diskless boot hook) handler.
  6451 000002FF 90EB10FFFFFFFF4B42-     iispentry intr18, 0, sharedentry3
  6451 00000308 00EB7700<rep 7h>   
  6452 00000312 2EC706[0000][0000]      	mov word [cs:run_int], int18msg	; remember interrupt type
  6453                                  %endif
  6454                                  %if _CATCHINT19
  6455 00000319 EB27                    	jmp intrtn			; jump to register saving routine
  6456                                  
  6457                                  
  6458                                  		; Interrupt 19h (boot load) handler.
  6459 0000031B 90EB10FFFFFFFF4B42-     iispentry intr19, 0, sharedentry3
  6459 00000324 00EB5B00<rep 7h>   
  6460 0000032E 2EC706[0000][0000]      	mov word [cs:run_int], int19msg	; remember interrupt type
  6461 00000335 2EC706[0000][0000]      	mov word [cs:lastcmd], dmycmd	; disable T/P/G auto-repeat
  6462 0000033C 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 00000342 FA                      	cli				; just in case
  6471 00000343 2E8F06[0000]            	pop word [cs:reg_eip]		; recover things from stack
  6472 00000348 2E8F06[0000]            	pop word [cs:reg_cs]
  6473 0000034D 2E8F06[0000]            	pop word [cs:reg_efl]
  6474 00000352 2E8C1E[0000]            	mov word [cs:reg_ds], ds	; ! word-aligned (AC flag)
  6475 00000357 2EA3[0000]              	mov word [cs:reg_eax], ax	; ! word-aligned (AC flag)
  6476 0000035B 8CC8                    	mov ax, cs
  6477 0000035D 8ED8                    	mov ds, ax			; => lDEBUG_DATA_ENTRY
  6478                                  
  6479 0000035F 90                      	align 4, nop
  6480                                  patcharea_intrtn:
  6481 00000360 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 00000380 EB01                    	jmp intrtn_entry
  6494                                  %endif
  6495                                  
  6496                                  sharedentry3.hwreset:
  6497 00000382 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                                  	mov byte [pm_2_86m_0], 0
  6512                                  	clropt [internalflags], protectedmode	; reset PM flag
  6513                                  .from_installdpmi:
  6514                                  %endif
  6515 00000383 8C16[0000]              	mov word [reg_ss], ss	; save stack position
  6516 00000387 8326[0200]00            _386	and word [reg_eip+2], byte 0	; we're from real mode
  6517 0000038C 66                      	_386_o32		; mov dword [reg_esp], esp
  6518 0000038D 8926[0000]              	mov word [reg_esp], sp
  6519 00000391 8ED0                    	mov ss, ax		; mov ss, cs	; (don't use the stack here)
  6520                                  
  6521                                  %if _PM
  6522                                  	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                                  	mov word [ss:reg_ds], ds	; ! word-aligned (AC flag)
  6530                                  	mov word [ss:reg_eax], ax	; ! word-aligned (AC flag)
  6531                                  	mov ax, ss
  6532                                  	mov ds, ax		; mov ds, ss
  6533                                  @@:
  6534                                  %endif
  6535 00000393 B80200                  	mov ax, 2
  6536                                  %ifn _ONLY386
  6537 00000396 EB1A                    	_386_jmps .386			; -->
  6538 00000398 BC[0200]                	mov sp, reg_es+2
  6539 0000039B 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 0000039C 83EC06                  	sub sp, byte 3*2
  6544 0000039F 57                      	push di
  6545 000003A0 29C4                    	sub sp, ax
  6546 000003A2 56                      	push si
  6547 000003A3 29C4                    	sub sp, ax
  6548 000003A5 55                      	push bp
  6549                                  	; sub sp, ax
  6550                                  	; sub sp, ax			; sp already saved
  6551                                  	; sub sp, ax
  6552 000003A6 83EC06                  	sub sp, byte 3*2
  6553 000003A9 52                      	push dx
  6554 000003AA 29C4                    	sub sp, ax
  6555 000003AC 51                      	push cx
  6556 000003AD 29C4                    	sub sp, ax
  6557 000003AF 53                      	push bx
  6558                                  %endif
  6559                                  %ifn _ONLYNON386
  6560                                   %ifn _ONLY386
  6561 000003B0 EB34                    	jmp short .common
  6562                                   %endif
  6563                                  
  6564                                  .386:
  6565                                  [cpu 386]
  6566 000003B2 66BC[02000000]          	mov esp, reg_gs+2
  6567 000003B8 0FA8                    	push gs
  6568 000003BA 29C4                    	sub sp, ax			; don't overwrite high words of segments
  6569 000003BC 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 000003BE 83EC0A                  	sub sp, byte 5*2
  6576 000003C1 06                      	push es
  6577                                  	; sub sp, ax
  6578                                  	; sub sp, ax			; ds already saved
  6579 000003C2 83EC04                  	sub sp, byte 2*2
  6580 000003C5 6657                    	push edi
  6581 000003C7 6656                    	push esi
  6582 000003C9 6655                    	push ebp
  6583                                  	; sub sp, ax
  6584                                  	; sub sp, ax			; sp already saved
  6585 000003CB 83EC04                  	sub sp, byte 2*2
  6586 000003CE 6652                    	push edx
  6587 000003D0 6651                    	push ecx
  6588 000003D2 669C                    	 pushfd				; (this overwrites reg_ebx)
  6589 000003D4 01C4                    	 add sp, ax			; discard low word of efl
  6590 000003D6 8F06[0200]              	 pop word [reg_efl+2]
  6591 000003DA 6A00                    	 push 0
  6592 000003DC 9C                      	 pushf				; (this also overwrites reg_ebx)
  6593 000003DD 669D                    	 popfd				; clear high word of efl inside debugger (resets AC flag)
  6594 000003DF 6653                    	push ebx
  6595 000003E1 A1[0000]                	mov ax, word [reg_eax]		; restore ax
  6596 000003E4 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 000003E6 66                      	_386_o32		; mov esp, dword [run_sp]
  6609 000003E7 8B26[0000]              	mov sp, word [run_sp]		; restore running stack
  6610 000003EB 0326[0000]              	add sp, word [run_sp_reserve]
  6611 000003EF FC                      	cld				; clear direction flag
  6612 000003F0 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 000003F1 E8(0000)                	call entry_to_code_segsel
  6624 000003F4 [EA13]                  	dw .code
  6625                                  
  6626                                  	usesection lDEBUG_CODE
  6626          ------------------       note: usesection lDEBUG_CODE
  6627                                  .code:
  6628                                  %endif
  6629                                  
  6630                                  %if _PM
  6631                                  	call handle_mode_changed
  6632                                  %endif
  6633                                  
  6634 000013EA E8F2F4                  	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 000013ED F606[0100]01            	testopt [internalflags6], dif6_debug_mode
  6643 000013F2 742C                    	jz .skipints
  6644 000013F4 E80200                  	call reset_interrupts
  6645 000013F7 EB27                    	jmp .skipints
  6646                                  
  6647                                  reset_interrupts: equ $
  6648                                   %endif
  6649 000013F9 51                      	push cx
  6650 000013FA 56                      	push si
  6651 000013FB 57                      	push di
  6652 000013FC 50                      	push ax
  6653 000013FD 53                      	push bx
  6654 000013FE 52                      	push dx
  6655 000013FF 55                      	push bp
  6656                                  
  6657                                  %if _PM
  6658                                  	call ispm
  6659                                  	jz @F			; in PM -->
  6660                                  	testopt [internalflags], canswitchmode
  6661                                  	jz @FF			; in 86 Mode and cannot switch to PM -->
  6662                                  
  6663                                  d4	call d4message
  6664                                  d4	asciz "In intrtn1_code (switch mode before calling pm_reset_handlers)",13,10
  6665                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  6666                                  	mov al, 0
  6667                                  	call sr_state		; save state
  6668                                  	call switchmode 	; switch to PM
  6669                                  		; ! handle_mode_changed not called here !
  6670                                  		; do not call InDOS or other functions using seg/sels
  6671                                  @@:
  6672                                  	call pm_reset_handlers
  6673                                  		; ! this calls resetmode
  6674                                  @@:
  6675                                  
  6676                                  	numdef OVERRIDE_BUILD_PM_DEBUG, 0
  6677                                   %if ! _CATCHPMINT214C && ! _OVERRIDE_BUILD_PM_DEBUG
  6678                                    %fatal Cannot build DDEBUGX: handler switching without Int21.4C hook untested
  6679                                   %endif
  6680                                  %endif
  6681                                  
  6682                                  %if CATCHINTAMOUNT
  6683                                  %if _CATCHINT06 && _DETECT95LX
  6684 00001400 8B0E[0000]              	mov cx, word [inttab_number_variable]
  6685                                  %else
  6686                                  	mov cx, inttab_number
  6687                                  %endif
  6688 00001404 E312                    	jcxz .intend
  6689 00001406 BE[0000]                	mov si, inttab
  6690 00001409 BAFFFF                  	mov dx, -1			; always force
  6691                                  .nextint:
  6692 0000140C AC                      	lodsb
  6693 0000140D 93                      	xchg ax, bx			; bl = number
  6694 0000140E AD                      	lodsw				; si -> list
  6695 0000140F 96                      	xchg ax, si			; si -> entry, ax -> list
  6696 00001410 93                      	xchg ax, bx			; al = number, bx -> list
  6697 00001411 E8(0000)                	call UnhookInterruptForce
  6698 00001414 87DE                    	xchg bx, si			; si -> list
  6699 00001416 E2F4                    	loop .nextint
  6700                                  
  6701                                  .intend:
  6702                                  %endif
  6703                                  
  6704 00001418 5D                      	pop bp
  6705 00001419 5A                      	pop dx
  6706 0000141A 5B                      	pop bx
  6707 0000141B 58                      	pop ax
  6708 0000141C 5F                      	pop di
  6709 0000141D 5E                      	pop si
  6710 0000141E 59                      	pop cx
  6711                                   %if _DEBUG_COND
  6712 0000141F C3                      	retn
  6713                                   %endif
  6714                                  .skipints:
  6715                                  %endif
  6716                                  
  6717 00001420 8026[0100]FE            	clropt [reg_efl], 100h		; clear TF
  6718                                  
  6719 00001425 E8(0000)                	call getpsp
  6720 00001428 891E[0000]              	mov word [pspdbe], bx
  6721                                  
  6722 0000142C E8(0000)                	call getint2324			; save debuggee's int 23/24, set debugger's int 23/24
  6723                                  
  6724 0000142F 16                      	 push ss
  6725 00001430 07                      	 pop es
  6726 00001431 E8(0000)                	call setpspdbg			; set PSP of debugger
  6727                                  
  6728 00001434 800E[0100]30            	setopt [internalflags], debuggerA20|debuggeeA20	; assume A20 is on
  6729                                  %if _PM
  6730                                  	call ispm
  6731                                  	jz .a20done			; assume A20 on. (is this the right thing to do?)
  6732                                  %endif
  6733 00001439 06                      	push es
  6734 0000143A 1E                      	push ds
  6735 0000143B 57                      	push di
  6736 0000143C 56                      	push si
  6737 0000143D 51                      	push cx
  6738 0000143E 31F6                    	xor si, si
  6739 00001440 8EDE                    	mov ds, si			; ds = 0000h
  6740 00001442 4E                      	dec si
  6741 00001443 8EC6                    	mov es, si			; es = FFFFh
  6742 00001445 46                      	inc si				; ds:si = 0000h:0000h =  00000h
  6743 00001446 BF1000                  	mov di, 0010h			; es:di = FFFFh:0010h = 100000h (same address if it overflows)
  6744 00001449 89F9                    	mov cx, di			; 32 byte (16 = 10h word)
  6745 0000144B F3A7                    	repe cmpsw			; compare them and assume A20 line switched off if same
  6746 0000144D 59                      	pop cx
  6747 0000144E 5E                      	pop si
  6748 0000144F 5F                      	pop di
  6749 00001450 1F                      	pop ds
  6750 00001451 07                      	pop es
  6751 00001452 7505                    	jne .a20done			; not equal, A20 line is switched on -->
  6752                                  					; if equal, the A20 line is probably switched off
  6753 00001454 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 00001459 C606[0000]01            	mov byte [bInDbg], 1
  6793                                  %if _CATCHINT19
  6794 0000145E 813E[0000][0000]        	cmp word [run_int], int19msg
  6795 00001464 7505                    	jne @F
  6796 00001466 800E[0200]20            	setopt [internalflags3], dif3_gotint19
  6797                                  %endif
  6798                                  @@:
  6799 0000146B 813E[0000][0000]        	cmp word [run_int], progtrm
  6800 00001471 7505                    	jnz @F
  6801 00001473 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 00001478 B001                    	mov al, 1		; restore debugger screen
  6810 0000147A E8(0000)                	call swapscreen
  6811                                   %ifn _VXCHGBIOS
  6812 0000147D 06                      	push es
  6813 0000147E B84000                  	mov ax, 0040h
  6814 00001481 8EC0                    	mov es, ax
  6815 00001483 26A08400                	mov al, [es:84h]	; did the number of screen rows change?
  6816 00001487 268A3E6200              	mov bh, [es:62h]
  6817 0000148C 883E[0000]              	mov [vpage], bh
  6818 00001490 3A06[0000]              	cmp al, [vrows]
  6819 00001494 A2[0000]                	mov [vrows], al
  6820 00001497 7419                    	jz @F
  6821                                  
  6822 00001499 F606[0000]01            	testopt [internalflags6], dif6_vv_mode
  6823 0000149E 7412                    	jz @F
  6824                                  
  6825 000014A0 88C6                    	mov dh, al		; yes. we cannot fully restore, but at least
  6826 000014A2 B200                    	mov dl, 0		;  clear bottom line to ensure the debugger displays
  6827                                  				;  will be seen
  6828 000014A4 B402                    	mov ah, 2		; set cursor position
  6829 000014A6 CD10                    	int 10h
  6830 000014A8 B307                    	mov bl, 7		; BH=video page, BL=attribute
  6831 000014AA B95000                  	mov cx, 80		; CX=columns
  6832 000014AD B82009                  	mov ax, 0920h		; AL=char to display
  6833 000014B0 CD10                    	int 10h
  6834                                  @@:
  6835 000014B2 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 000014B3 E80100                  	call setscreen
  6847                                  %endif
  6848                                  
  6849 000014B6 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 000014B7 C3                      	retn	; will be patched to "push ds" if "/2" cmdline switch and second adapter exists
  6867                                  		; (SMC in section lDEBUG_CODE)
  6868 000014B8 8B16[0000]              	mov dx, [oldcrtp]
  6869 000014BC 8B1E[0000]              	mov bx, [oldcols]
  6870 000014C0 A1[0000]                	mov ax, [oldmr]
  6871 000014C3 B94000                  	mov cx, 0040h         ; 0040h is supposed to work in both rm/pm
  6872 000014C6 8ED9                    	mov ds, cx
  6873 000014C8 368B0E[0000]            	mov cx, [ss:oldcsrpos]
  6874 000014CD 80261000CF              	and byte [10h], ~ 30h
  6875 000014D2 80FAB4                  	cmp dl, 0B4h
  6876 000014D5 7505                    	jnz @F
  6877 000014D7 800E100030              	or  byte [10h], 30h
  6878                                  @@:
  6879 000014DC 871E4A00                	xchg bx, [4Ah]
  6880 000014E0 870E5000                	xchg cx, [50h]
  6881 000014E4 87166300                	xchg dx, [63h]
  6882 000014E8 86064900                	xchg al, [49h]
  6883 000014EC 86268400                	xchg ah, [84h]
  6884 000014F0 1F                      	pop ds
  6885 000014F1 8916[0000]              	mov [oldcrtp], dx
  6886 000014F5 890E[0000]              	mov [oldcsrpos], cx
  6887 000014F9 891E[0000]              	mov [oldcols], bx
  6888 000014FD A3[0000]                	mov [oldmr], ax
  6889 00001500 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                                  	mov si, convsegs
  6921                                  	mov cx, convsegs.amount
  6922                                  
  6923                                  	call ispm
  6924                                  	jz .now_pm
  6925                                  [cpu 286]
  6926                                  .now_86m:
  6927                                  	testopt [internalflags3], dif3_prior_pm
  6928                                  	jz .from_no_change
  6929                                  %if _MMXSUPP && _MMX_REDETECT
  6930                                  	call mmx_redetect
  6931                                  %endif
  6932                                  .from_pm_now_86m:
  6933                                  .from_pm_now_86m.loop:
  6934                                  	lodsw
  6935                                  	xchg ax, di
  6936                                  	cmp si, convsegs.end_fixed
  6937                                  	ja @F
  6938                                  	mov dx, word [di + soaSegment]
  6939                                  	mov word [di + soaSegSel], dx
  6940                                  	loop .from_pm_now_86m.loop
  6941                                  	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                                  	testopt [internalflags], modeswitched
  6947                                  	jnz .from_done_change		; cancel this -->
  6948                                  
  6949                                  	testopt [internalflags], canswitchmode
  6950                                  	jnz @FF
  6951                                  	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                                  	lodsw
  6961                                  	xchg ax, di
  6962                                  @@:
  6963                                  	xor dx, dx
  6964                                  	mov word [di + soaSegment], dx
  6965                                  	mov word [di + soaSegSel], dx
  6966                                  	loop .from_pm_now_86m.loop.nonfixed.nomodeswitch
  6967                                  	jmp .from_done_change
  6968                                  
  6969                                  @@:
  6970                                  	push cx
  6971                                  	push di
  6972                                  	push si
  6973                                  d4	call d4message
  6974                                  d4	asciz "In intrtn1_code.from_pm_now_86m (switching modes to access selectors)",13,10
  6975                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  6976                                  	mov al, 0
  6977                                  	call sr_state			; save state
  6978                                  	call switchmode 		; switch to PM
  6979                                  		; ! handle_mode_changed not called here !
  6980                                  		; do not call InDOS or other functions using seg/sels
  6981                                  	pop si
  6982                                  	pop di
  6983                                  	jmp @F
  6984                                  
  6985                                  .from_pm_now_86m.loop.nonfixed:
  6986                                  	lodsw
  6987                                  	xchg ax, di
  6988                                  	push cx
  6989                                  @@:
  6990                                  	xor bx, bx
  6991                                  	xchg bx, word [di + soaSelector]
  6992                                  	mov ax, 0006h
  6993                                  	int 31h
  6994                                  	jc @F				; fail -->
  6995                                  	test dl, 15
  6996                                  	jnz @F				; not on a segment boundary -->
  6997                                  	test cx, 0FFF0h
  6998                                  	jnz @F				; >= 1024 KiB -->
  6999                                  	shr dx, 4
  7000                                  	shl cx, 12
  7001                                  	or dx, cx
  7002                                  	db __TEST_IMM16			; (skip xor)
  7003                                  @@:
  7004                                  	xor dx, dx			; if no valid segment
  7005                                  	mov word [di + soaSegment], dx
  7006                                  	pop cx
  7007                                  	mov word [di + soaSegSel], dx
  7008                                  	loop .from_pm_now_86m.loop.nonfixed
  7009                                  	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                                  	jmp .from_done_change
  7016                                  __CPU__
  7017                                  
  7018                                  .now_pm:
  7019                                  	testopt [internalflags3], dif3_prior_pm
  7020                                  	jnz .from_no_change
  7021                                  %if _MMXSUPP && _MMX_REDETECT
  7022                                  	call mmx_redetect
  7023                                  %endif
  7024                                  .from_86m_now_pm:
  7025                                  .from_86m_now_pm.loop:
  7026                                  	lodsw
  7027                                  	xchg ax, di
  7028                                  	cmp si, convsegs.end_fixed
  7029                                  	ja @F
  7030                                  
  7031                                  	mov ax, word [di + soaSelector]
  7032                                  	test ax, ax
  7033                                  	jnz .no_dosdata_change
  7034                                  	mov bx, word [di + soaSegment]
  7035                                  	mov ax, 0002h
  7036                                  	int 31h
  7037                                  	mov word [di + soaSelector], ax
  7038                                  
  7039                                  .no_dosdata_change:
  7040                                  	mov word [di + soaSegSel], ax
  7041                                  	jmp @FFF
  7042                                  
  7043                                  @@:
  7044                                  		; Magic: Do not modify if called during modeswitching.
  7045                                  	testopt [internalflags], modeswitched
  7046                                  	jnz .from_done_change		; cancel this -->
  7047                                  
  7048                                  	mov bx, word [di + soaSegment]
  7049                                  	mov ax, 0002h
  7050                                  	int 31h
  7051                                  	jnc @F
  7052                                  	xor ax, ax
  7053                                  @@:
  7054                                  	mov word [di + soaSegSel], ax
  7055                                  	mov word [di + soaSelector], ax
  7056                                  	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                                  	loop .from_86m_now_pm.loop
  7066                                  %endif
  7067                                  .from_done_change:
  7068                                  .from_no_change:
  7069                                  
  7070                                  
  7071                                  remember_mode:
  7072                                  	clropt [internalflags3], dif3_prior_pm
  7073                                  	call ispm
  7074                                  	jnz .from_86m
  7075                                  .from_pm:
  7076                                  	setopt [internalflags3], dif3_prior_pm
  7077                                  .from_86m:
  7078                                  	retn
  7079                                  %endif
  7080                                  
  7081                                  
  7082                                  %if _MMXSUPP && _MMX_REDETECT && _PM
  7083                                  mmx_redetect:
  7084                                  _no386	retn
  7085                                  %ifn _ONLYNON386
  7086                                  subcpu 386
  7087                                  	push eax
  7088                                  	push ebx
  7089                                  	push ecx
  7090                                  	push edx
  7091                                  
  7092                                  	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                                  	mov bx, sp		; save current stack pointer to align
  7097                                  	and sp, ~3		; align stack to avoid AC fault
  7098                                  	pushfd			; push original EFLAGS
  7099                                  	pop eax			; get original EFLAGS
  7100                                  	mov ecx, eax		; save original EFLAGS in ECX (including IF)
  7101                                  
  7102                                  	xor eax, 40000h		; flip AC bit in EFLAGS
  7103                                  	and ax, ~0200h		; clear IF
  7104                                  	push eax		; put new EFLAGS value on stack
  7105                                  	popfd			; replace EFLAGS value; DI
  7106                                  	pushfd			; get new EFLAGS
  7107                                  	pop eax			; store new EFLAGS value in EAX
  7108                                  	mov ax, cx		; ignore low bits (including IF)
  7109                                  	cmp eax, ecx
  7110                                  	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                                  	mov eax, ecx		; get original EFLAGS
  7117                                  	xor eax, 200000h	; flip ID bit in EFLAGS
  7118                                  	and ax, ~0200h		; clear IF
  7119                                  	push eax		; save new EFLAGS value on stack
  7120                                  	popfd			; replace current EFLAGS value; DI
  7121                                  	pushfd			; get new EFLAGS
  7122                                  	pop eax			; store new EFLAGS in EAX
  7123                                  	mov ax, cx		; ignore low bits (including IF)
  7124                                  
  7125                                  .cpudone_stack_eax_equals_ecx:
  7126                                  	push ecx
  7127                                  	popfd			; restore AC,ID bits and IF in EFLAGS (86 Mode)
  7128                                  	mov sp, bx		; restore sp
  7129                                  
  7130                                  	cmp eax, ecx		; check if it's changed
  7131                                  	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                                  	xor eax, eax		; set up input for CPUID instruction
  7140                                  	  [cpu 586]
  7141                                  	 cpuid
  7142                                  	  __CPU__
  7143                                  	cmp eax, byte 1
  7144                                  	jb .cpudone		; if 1 is not a valid input value for CPUID
  7145                                  	xor eax, eax		; otherwise, run CPUID with eax = 1
  7146                                  	inc eax
  7147                                  	  [cpu 586]
  7148                                  	 cpuid
  7149                                  	  __CPU__
  7150                                  	test edx, 80_0000h
  7151                                  	setnz byte [has_mmx]
  7152                                  .cpudone:
  7153                                  	pop edx
  7154                                  	pop ecx
  7155                                  	pop ebx
  7156                                  	pop eax
  7157                                  	retn
  7158                                  
  7159                                  subcpureset
  7160                                  subcpureset
  7161                                  %endif
  7162                                  %endif
  7163                                  
  7164                                  
  7165                                  %if _PM && _DEBUG
  7166                                  		; INP:	-
  7167                                  		; OUT:	es = ds
  7168                                  		; CHG:	eax, edx, bx, cx, bp, si, di
  7169                                  		; STT:	in PM
  7170                                  		;	do not call InDOS or other functions using seg/sels
  7171                                  pm_set_handlers:
  7172                                  	xor bp, bp		; = 0 if no 386
  7173                                  _386	inc bp
  7174                                  _386	inc bp			; = 2 if 386
  7175                                  
  7176                                  	 push ds
  7177                                  	 pop es
  7178                                  
  7179                                  	mov si, exctab		; hook several exceptions
  7180                                  %if _DEBUGUPDATESAVE
  7181                                  	mov di, excsave
  7182                                  %endif
  7183                                  _386	xor edx, edx		; clear edxh
  7184                                  	mov dx, exc_first
  7185                                  .loopexc:
  7186                                  	lodsb
  7187                                  	mov bl, al
  7188                                  
  7189                                  %if _DEBUGUPDATESAVE
  7190                                  	_386_o32	; push edx
  7191                                  	push dx			; preserve excXX pointer
  7192                                  	mov ax, 0202h
  7193                                  		; (edxh is zero)
  7194                                  	int 31h			; cx:(e)dx -> prior handler
  7195                                  	_386_o32	; xchg eax, edx
  7196                                  	xchg ax, dx
  7197                                  	_386_o32	; stosd
  7198                                  	stosw			; store offset (dword on 386+, else word)
  7199                                  	xchg ax, cx
  7200                                  	stosw			; store selector
  7201                                  	mov ax, 4
  7202                                  	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7203                                  	add di, ax		; -> next entry of excsave
  7204                                  	_386_o32	; pop edx
  7205                                  	pop dx
  7206                                  %endif
  7207                                  
  7208                                  	mov cx, word [cssel]	; -> our handler for this exception
  7209                                  	mov ax, 0203h
  7210                                  	int 31h			; set our handler
  7211                                   %ifn _LINK
  7212                                  	add dx, byte exc_second - exc_first
  7213                                   %else
  7214                                  	add dx, strict byte 0
  7215                                   wlcalc byte_ext_exc_second, equ $ - 1
  7216                                   wlcalc byte_minusext_exc_first, equ $ - 1
  7217                                   %endif
  7218                                  				; -> next handler
  7219                                  	cmp si, endexctab	; if another to go -->
  7220                                  	jb .loopexc
  7221                                  
  7222                                   %if _CATCHPMINT214C
  7223                                  	mov si, pminttab	; ds:si -> pminttab
  7224                                    %if _DEBUGUPDATESAVE
  7225                                  	mov di, pmintsave	; es:di -> pmintsave
  7226                                    %endif
  7227                                  .loopint:
  7228                                  	lodsb			; get interrupt number
  7229                                  	mov bl, al		; bl = interrupt number
  7230                                  
  7231                                    %if _DEBUGUPDATESAVE
  7232                                  _386	xor edx, edx		; clear edxh
  7233                                  	mov ax, 0204h
  7234                                  	int 31h			; cx:(e)dx -> prior handler
  7235                                  	_386_o32	; xchg eax, edx
  7236                                  	xchg ax, dx		; (e)ax = offset
  7237                                  	_386_o32	; stosd
  7238                                  	stosw			; store offset (dword on 386+, else word)
  7239                                  	xchg ax, cx
  7240                                  	stosw			; store selector
  7241                                  	mov ax, 4
  7242                                  	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7243                                  	add di, ax		; -> next entry of pmintsave
  7244                                    %endif
  7245                                  
  7246                                  	lodsw			; ax -> our handler
  7247                                  _386	xor edx, edx
  7248                                  	xchg ax, dx		; (e)dx -> our handler
  7249                                  	mov cx, word [cssel]	; cx:(e)dx -> our handler
  7250                                  	mov ax, 0205h
  7251                                  	int 31h
  7252                                  	cmp si, pminttab.end
  7253                                  	jb .loopint
  7254                                   %endif
  7255                                  
  7256                                  	jmp resetmode
  7257                                  %endif
  7258                                  
  7259                                  
  7260                                  %if _PM && (_CATCHPMINT214C || _DEBUG || _TSR || _DEVICE)
  7261                                  		; INP:	-
  7262                                  		; OUT:	-
  7263                                  		; CHG:	eax, edx, bx, cx, bp, si, di
  7264                                  		; STT:	in PM
  7265                                  		;	do not call InDOS or other functions using seg/sels
  7266                                  pm_reset_handlers:
  7267                                  	xor bp, bp		; = 0 if no 386
  7268                                  _386	inc bp
  7269                                  _386	inc bp			; = 2 if 386
  7270                                  
  7271                                  
  7272                                   %if CATCHEXCAMOUNT
  7273                                  		; unhook exceptions
  7274                                  	mov di, exctab
  7275                                  	mov si, excsave
  7276                                  .loopexc:
  7277                                  	mov bl, [di]		; bl = exception number
  7278                                  	inc di
  7279                                  	_386_o32	; lodsd
  7280                                  	lodsw			; load offset (dword on 386+, else word)
  7281                                  	_386_o32	; xchg eax, edx
  7282                                  	xchg ax, dx
  7283                                  	lodsw			; load selector
  7284                                  	xchg ax, cx		; cx:(e)dx -> prior handler
  7285                                  	mov ax, 4
  7286                                  	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7287                                  	add si, ax		; -> next entry of excsave
  7288                                  	mov ax, 0203h
  7289                                  	int 31h			; set previous handler
  7290                                  	cmp di, endexctab	; if another to go -->
  7291                                  	jb .loopexc
  7292                                   %endif
  7293                                  
  7294                                  
  7295                                   %if CATCHPMINTAMOUNT
  7296                                  		; unhook interrupts
  7297                                  	mov di, pminttab	; ds:di -> pminttab
  7298                                  	mov si, pmintsave	; ds:si -> pmintsave
  7299                                  .loopint:
  7300                                  	mov bl, [di]		; bl = interrupt number
  7301                                  	add di, 3		; -> after this pminttab entry
  7302                                  	_386_o32	; lodsd
  7303                                  	lodsw			; load offset (dword on 386+, else word)
  7304                                  	_386_o32	; xchg eax, edx
  7305                                  	xchg ax, dx
  7306                                  	lodsw			; load selector
  7307                                  	xchg ax, cx		; cx:(e)dx -> prior handler
  7308                                  	mov ax, 4
  7309                                  	sub ax, bp		; if 386, ax = 4 - 2 = 2, else ax = 4
  7310                                  	add si, ax		; -> next entry of pmintsave
  7311                                  	mov ax, 0205h
  7312                                  	int 31h			; set previous handler
  7313                                  	cmp di, pminttab.end	; if another to go -->
  7314                                  	jb .loopint
  7315                                   %endif
  7316                                  
  7317                                  	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 000003F6 00<rep 2h>              	align 4, db 0
  7391 000003F8 01000000                default_pp_count:	dd 1
  7392 000003FC 01000000                default_tp_count:	dd 1
  7393 00000400 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 00001501 E8(0000)                	call guard_re
  7408 00001504 C706[0000][0000]        	mov word [gg_deferred_message], msg.empty_message
  7409 0000150A 8326[0000]00            	and word [bb_deferred_message_in_lineout_behind], 0
  7410 0000150F 8026[0000]F7            	clropt [internalflags2], dif2_gg_is_gg
  7411 00001514 8026[0300]2B            	clropt [internalflags], 		tt_while | tt_silent_mode | tt_no_bb | tt_no_bb_first
  7413 00001519 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 0000151E 3C2E                    	cmp al, '.'
  7421 00001520 7520                    	jne .no_dot
  7422                                  
  7423 00001522 AD                      	lodsw
  7424 00001523 25DFDF                  	and ax, TOUPPER_W
  7425 00001526 3D4E42                  	cmp ax, "NB"
  7426 00001529 7411                    	je .dot_nb
  7427                                  		; TP.SB, T.SB, P.SB: trace/proceed without bb for first step
  7428 0000152B 3D5342                  	cmp ax, "SB"
  7429 0000152E 7405                    	je .dot_sb
  7430 00001530 4E                      	dec si
  7431 00001531 4E                      	dec si
  7432 00001532 E9(0000)                	jmp error
  7433                                  
  7434                                  .dot_sb:
  7435 00001535 800E[0300]80            	setopt [internalflags], tt_no_bb_first
  7436 0000153A EB05                    	jmp .dot_common
  7437                                  
  7438                                  .dot_nb:
  7439 0000153C 800E[0300]40            	setopt [internalflags], tt_no_bb
  7440                                  .dot_common:
  7441 00001541 AC                      	lodsb
  7442                                  .no_dot:
  7443 00001542 E84F01                  	call parseql		; process =addr
  7444 00001545 E8(0000)                	call skipcomm0		; skip any white space
  7445                                  
  7446 00001548 BA0400                  	mov dx, opt3_pp_no_paging
  7447 0000154B 8B1E[FA03]              	mov bx, word [default_pp_count + 2]
  7448 0000154F 8B0E[F803]              	mov cx, word [default_pp_count]
  7449 00001553 F606[0100]10            	testopt [internalflags2], dif2_is_pp
  7450 00001558 751D                    	jnz @F
  7451 0000155A BA0200                  	mov dx, opt3_tp_no_paging
  7452 0000155D 8B1E[FE03]              	mov bx, word [default_tp_count + 2]
  7453 00001561 8B0E[FC03]              	mov cx, word [default_tp_count]
  7454 00001565 F606[0300]08            	testopt [internalflags], tt_p
  7455 0000156A 750B                    	jnz @F
  7456 0000156C BA0100                  	mov dx, opt3_tt_no_paging
  7457 0000156F 8B1E[0204]              	mov bx, word [default_tt_count + 2]
  7458 00001573 8B0E[0004]              	mov cx, word [default_tt_count]
  7459                                  @@:				; bx:cx = default count
  7460                                  
  7461 00001577 8516[0000]              	test word [options3], dx
  7462 0000157B 7405                    	jz @F
  7463 0000157D 8026[0000]F7            	clropt [internalflags], pagedcommand
  7464                                  @@:
  7465                                  
  7466                                  		; Initialise auxbuff pointers.
  7467 00001582 E8F900                  	call tpg_initialise_empty_auxbuff
  7468                                  
  7469 00001585 E8(0000)                	call iseol?
  7470                                  %if _LINK_COMPAT
  7471 00001588 7503                    	jne @F
  7472 0000158A E97E00                  	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 0000158D E8(0000)                	nearcall getdword	; bx:dx = given count
  7478                                  
  7479 00001590 53                      	push bx
  7480 00001591 52                      	push dx			; push count
  7481 00001592 E8(0000)                	call skipcomm0
  7482 00001595 E8(0000)                	call iseol?
  7483 00001598 746F                    	je .no_while
  7484 0000159A 4E                      	dec si
  7485 0000159B BA[0000]                	mov dx, msg.while
  7486 0000159E E8(0000)                	call isstring?
  7487 000015A1 7405                    	je .found_while
  7488                                  
  7489 000015A3 E8AE00                  	call .handle_silent	; (error if no SILENT keyword)
  7490                                  
  7491 000015A6 EB61                    	jmp .no_while
  7492                                  
  7493                                  
  7494                                  .found_while:
  7495 000015A8 E8(0000)                	call skipcomma
  7496 000015AB 4E                      	dec si
  7497 000015AC 89F1                    	mov cx, si
  7498 000015AE AC                      	lodsb
  7499 000015AF E8(0000)                	nearcall getexpression
  7500 000015B2 E8(0000)                	nearcall toboolean
  7501 000015B5 E8(0000)                	call skipcomm0
  7502 000015B8 52                      	push dx
  7503 000015B9 56                      	push si
  7504 000015BA E8(0000)                	call iseol?		; expect end of line here
  7505 000015BD 7404                    	je .no_while_silent
  7506                                  
  7507 000015BF 4E                      	dec si
  7508 000015C0 E89100                  	call .handle_silent
  7509                                  
  7510                                  .no_while_silent:
  7511 000015C3 5E                      	pop si
  7512 000015C4 5A                      	pop dx
  7513 000015C5 85D2                    	test dx, dx		; condition true now ?
  7514 000015C7 750F                    	jnz @F
  7515                                  
  7516 000015C9 BA[0000]                	mov dx, msg.while_not_true
  7517 000015CC E8(0000)                	call putsz
  7518 000015CF B83601                  	mov ax, 0136h
  7519 000015D2 E8(0000)                	call setrc
  7520 000015D5 E9(0000)                	jmp cmd3
  7521                                  
  7522                                  @@:
  7523                                  		; (si + 1) -> line terminator (13, ';', 0) or next keyword
  7524                                  @@:
  7525 000015D8 4E                      	dec si			; -> terminator, or blank
  7526 000015D9 807CFF20                	cmp byte [si - 1], 32	; another blank at end ?
  7527 000015DD 74F9                    	je @B			; yes -->
  7528 000015DF 807CFF09                	cmp byte [si - 1], 9
  7529 000015E3 74F3                    	je @B			; yes -->
  7530 000015E5 807CFF2C                	cmp byte [si - 1], ','	; comma at end ?
  7531 000015E9 74ED                    	je @B			; yes -->
  7532 000015EB 89F0                    	mov ax, si
  7533 000015ED 29C8                    	sub ax, cx		; ax = length of expression
  7534 000015EF 3D[FFFF]                	cmp ax, while_buffer.length - 1
  7535 000015F2 7603E9(0000)            	ja error
  7536 000015F7 57                      	push di
  7537 000015F8 BF[0000]                	mov di, while_buffer
  7538 000015FB 89CE                    	mov si, cx		; -> expression start
  7539 000015FD 91                      	xchg cx, ax		; cx = length of expression
  7540 000015FE F3A4                    	rep movsb		; store expression
  7541 00001600 B000                    	mov al, 0
  7542 00001602 AA                      	stosb			; terminate string
  7543 00001603 5F                      	pop di
  7544                                  
  7545 00001604 800E[0300]04            	setopt [internalflags], tt_while
  7546                                  .no_while:
  7547 00001609 59                      	pop cx
  7548 0000160A 5B                      	pop bx			; bx:cx = given count
  7549                                  
  7550                                  .ppt1:
  7551 0000160B 85DB                    	test bx, bx
  7552 0000160D 7507                    	jnz @F
  7553 0000160F 85C9                    	test cx, cx
  7554 00001611 7503E9(0000)            	jz error		; must be at least 1, else error -->
  7555                                  @@:
  7556 00001616 53                      	push bx
  7557 00001617 51                      	push cx
  7558                                  
  7559 00001618 8026[0000]E8            	clropt [internalflags2], 		dif2_gg_is_first | dif2_gg_first_detected 		| dif2_gg_skip_cseip | dif2_gg_skip_non_cseip
  7562                                  
  7563 0000161D F606[0200]04            	testopt [options], tp_do_not_skip_bp
  7564 00001622 752A                    	jnz .do_not_skip_cseip
  7565 00001624 800E[0000]01            	setopt [internalflags2], dif2_gg_is_first
  7566                                  
  7567 00001629 803E[0000]00            	cmp byte [eqflag], 0
  7568 0000162E 7507                    	jne .cseip_take_eql
  7569                                  
  7570                                  	_386_PM_o32		; xor ecx, ecx
  7571 00001630 31C9                    	xor cx, cx
  7572 00001632 E82EF2                  	call get_cseip_ecx_linear
  7573 00001635 EB0B                    	jmp .got_cseip
  7574                                  
  7575                                  .cseip_take_eql:
  7576 00001637 8B1E[0400]              	mov bx, word [eqladdr + 4]
  7577                                  	_386_PM_o32		; mov edx, dword [eqladdr]
  7578 0000163B 8B16[0000]              	mov dx, word [eqladdr]
  7579 0000163F E82BF2                  	call getlinear_d_b
  7580                                  .got_cseip:
  7581 00001642 7303E9(0000)            	jc error
  7582 00001647 A3[0000]                	mov word [gg_first_cseip_linear], ax
  7583 0000164A 8916[0200]              	mov word [gg_first_cseip_linear + 2], dx
  7584                                  .do_not_skip_cseip:
  7585                                  
  7586 0000164E 59                      	pop cx
  7587 0000164F 5B                      	pop bx
  7588                                  
  7589 00001650 E86100                  	call seteq		; make the = operand take effect
  7590 00001653 C3                      	retn
  7591                                  
  7592                                  
  7593                                  .handle_silent:
  7594 00001654 BA[0000]                	mov dx, msg.silent
  7595 00001657 E8(0000)                	call isstring?
  7596 0000165A 7403E9(0000)            	jne error
  7597 0000165F E8(0000)                	call skipcomma
  7598 00001662 4E                      	dec si
  7599 00001663 E8(0000)                	call skipequals
  7600 00001666 E8(0000)                	call iseol?
  7601 00001669 740A                    	je .no_silent_mode_number
  7602                                  
  7603 0000166B E8(0000)                	nearcall getword
  7604 0000166E 8916[0000]              	mov word [tt_silent_mode_number], dx
  7605 00001672 E8(0000)                	call chkeol
  7606                                  
  7607                                  .no_silent_mode_number:
  7608 00001675 E8(0000)                	call guard_auxbuff.1_or_2
  7609 00001678 800E[0300]10            	setopt [internalflags], tt_silent_mode
  7610 0000167D 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 0000167E 8B16[0000]              	mov dx, word [auxbuff_behind_last_silent]
  7622 00001682 F606[0200]10            	testopt [options6], opt6_rh_mode
  7623 00001687 7506                    	jnz .last
  7624                                  %endif
  7625                                  .reset:
  7626                                  %if _PM
  7627                                  	mov dx, word [auxbuff_switchbuffer_size]
  7628                                  %else
  7629 00001689 31D2                    	xor dx, dx
  7630                                  %endif
  7631 0000168B 8916[0000]              	mov word [auxbuff_behind_last_silent], dx
  7632                                  .last:
  7633                                  %if _RH
  7634 0000168F 8916[0000]              	mov word [auxbuff_start_silent], dx
  7635                                  %endif
  7636 00001693 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 00001694 C606[0000]00            	mov byte [eqflag], 0	; mark '=' as absent
  7650 00001699 3C3D                    	cmp al, '='
  7651 0000169B 7516                    	jne peq1		; if no '=' operand
  7652 0000169D E8(0000)                	call skipwhite
  7653 000016A0 8B1E[0000]              	mov bx, word [reg_cs]	; default segment
  7654 000016A4 E8(0000)                	nearcall getaddrX	; get the address into bx:(e)dx
  7655                                  	_386_PM_o32	; mov dword [eqladdr], edx
  7656 000016A7 8916[0000]              	mov word [eqladdr+0], dx
  7657 000016AB 891E[0400]              	mov word [eqladdr+4], bx
  7658 000016AF FE06[0000]              	inc byte [eqflag]
  7659                                  peq1:
  7660 000016B3 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 000016B4 803E[0000]00            	cmp byte [eqflag], 0
  7669 000016B9 7411                    	je .return		; if no `=' operand
  7670 000016BB A1[0000]                	mov ax, word [eqladdr+0]
  7671 000016BE A3[0000]                	mov word [reg_eip], ax
  7672                                  %if _PM
  7673                                  	mov ax, word [eqladdr+2]
  7674                                  	mov word [reg_eip+2], ax
  7675                                  %endif
  7676 000016C1 A1[0400]                	mov ax, word [eqladdr+4]
  7677 000016C4 A3[0000]                	mov word [reg_cs], ax
  7678 000016C7 C606[0000]00            	mov byte [eqflag], 0	; clear the flag
  7679                                  .return:
  7680 000016CC C3                      	retn
  7681                                  %endif	; !_LOADER
  7682                                  
  7683                                  usesection lDEBUG_CODE
  7683          ------------------       note: usesection lDEBUG_CODE
  7684                                  
  7685                                  ..@run_access_end:
