     1                                  
     2                                  %if 0
     3                                  
     4                                  lDebug - libre 86-DOS debugger
     5                                  
     6                                  Copyright (C) 1995-2003 Paul Vojta
     7                                  Copyright (C) 2008-2026 E. C. Masloch
     8                                  
     9                                  Usage of the works is permitted provided that this
    10                                  instrument is retained with the works, so that any entity
    11                                  that uses the works is notified of this instrument.
    12                                  
    13                                  DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                                  
    15                                  %endif
    16                                  
    17                                  %define SOURCEFILENAME "debug.asm"
    18                                  [list -]
    14                              <3> [list -]
    14                              <2> [list -]
    86                              <1> [list -]
    86          ------------------  <1>  note: Disable usesection detection
    86          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
    86          ------------------  <1>  note: usesection ASMTABLE1
    86          ------------------  <1>  note: usesection ASMTABLE2
    86          ------------------  <1>  note: usesection DATASTACKBASE
    86          ------------------  <1>  note: usesection MESSAGESEGMENT
    86          ------------------  <1>  note: usesection lDEBUG_CODE
    86          ------------------  <1>  note: usesection lDEBUG_CODE2
    86          ------------------  <1>  note: usesection INIT
    86          ------------------  <1>  note: usesection WLEMITALIGNINITEND
    86          ------------------  <1>  note: usesection DEVICESHIM
    86          ------------------  <1>  note: usesection WLEMITALIGNRELOCZERO
    68                              <2> %endif
    69                              <2> 
    70                              <2> 
    71                              <2> 	usesection lDEBUG_CODE
    71          ------------------  <2>  note: usesection lDEBUG_CODE
    72                              <2> section_of puts, trimputs, puts_ext_done, puts_ext_next
    73                              <2> section_of putsz_exthelp, code_retf
    74                              <2> section_of puts_getline_ext_done
    75                              <2> section_of puts_copyoutput_ext_done
    76                              <2> section_of guard_auxbuff, guard_re
    77                              <2> section_of handle_serial_flags_ctrl_c
    78                              <2> section_of hexword_high
    79                              <2> section_of call_int2D
    80                              <2> section_of copy_single_counted_string
    81                              <2> section_of intchk
    82                              <2> section_of IsIISPEntry?
    83                              <2> section_of dd_store
    84                              <2> section_of dohack, getsegmented, hexbyte, hexnyb, iseol?.notsemicolon
    85                              <2> section_of peekc, getc, prephack, readmem, setds2si, setds2bx, setes2dx
    86                              <2> section_of silence_get_start, silence_get_start.have_di, silence_count_zeroes
    87                              <2> section_of setrmlimit, skipcomm0, unhack
    88                              <2> section_of skipequals
    89                              <2> section_of to_errret_pop
    90                              <2> section_of cmd3.have_cx_convenience
    91                              <2> section_of verifysegm, verifysegm_or_error
    92                              <2> section_of pp16, resetmode, resetmode_and_test_d_b_bit
    93                              <2> section_of pp_fix32bitflags, proceedbreakpoint
    94                              <2> section_of putsz, hexword, skipcomma, cmd3, cmd3_not_ext, cmd3_preprocessed
    95                              <2> section_of hexdword
    96                              <2> section_of cmd3_not_inject, cmd3_injected
    97                              <2> section_of aa_not_inject, aa_injected, aa_before_getline, aa_after_getline
    98                              <2> section_of transfer_ext_cx_nearcall_from_code2
    99                              <2> section_of traceone, unexpectedinterrupt, dumpregs_no_disasm
   100                              <2> section_of aa_imm_entry, ia_restore_a_addr, ia_restore_u_addr, disasm
   101                              <2> section_of ia_restore_ds
   102                              <2> %ifn _SYMBOLIC
   103                              <2> section_of selector_to_segment
   104                              <2> %endif
   105                              <2> section_of disp_al, disp_al_hex, disp_al_nybble_hex, disp_ax_dec, disp_ax_hex
   106                              <2> section_of disp_dxax_times_cx_width_bx_size
   107                              <2> section_of disp_dxax_times_cx_width_bx_size.store
   108                              <2> section_of disp_message, disp_message_length_cx
   109                              <2> section_of ispm
   110                              <2> section_of setrc, error
   111                              <2> section_of _doscall, _doscall_return_es, _doscall_return_es_parameter_es_ds
   112                              <2> section_of intcall_ext_return_es, close_ext, doscall_extseg
   113                              <2> section_of yy_reset_buf
   114                              <2> section_of init_bootcmd
   115                              <2> 
   116                              <2> section_of InDOS, bootgetmemorysize
   117                              <2> section_of chkeol, decword, decdword
   118                              <2> section_of dec_dword_minwidth
   119                              <2> section_of getexpression.lit_isdigit?, getexpression.lit_ishexdigit?
   120                              <2> section_of getlinearaddr
   121                              <2> section_of getlinear_d_b
   122                              <2> section_of getlinear_high_limit
   123                              <2> section_of getlinear_32bit
   124                              <2> section_of getlinear_high_limit.do_not_use_test
   125                              <2> section_of getlinear_common
   126                              <2> section_of ifsep, iseol?, isseparator?, isstring?, movp
   127                              <2> section_of putc, putsline, putsline_crlf, putsz_error
   128                              <2> section_of setrmsegm
   129                              <2> section_of skipwh0, skipwhite
   130                              <2> section_of test_d_b_bit, test_high_limit, push_cxdx_or_edx
   131                              <2> section_of capitalise
   132                              <2> section_of setes2ax
   133                              <2> section_of zz_copy_strings_to_str_buffer
   134                              <2> section_of call_xms_move, zz_call_xms, zz_detect_xms
   135                              <2> section_of code2_to_code_ret_to_ext
   136                              <2> section_of yy_dos_parse_name, yy_open_file, yy_check_lfn
   137                              <2> section_of yy_common_parse_name
   138                              <2> section_of yy_common_parse_name_bx_buffer
   139                              <2> section_of retry_open_scriptspath
   140                              <2> section_of yy_boot_read.bx, yy_boot_seek_start.bx, yy_boot_seek_current.bx
   141                              <2> section_of yy_boot_parse_name, yy_boot_open_file
   142                              <2> section_of yy_boot_parse_name_bx_buffer
   143                              <2> section_of near_transfer_ext_return, scan_dir_aux, read_sector
   144                              <2> section_of yy_boot_init_dir, got_yyentry, scan_dir_entry
   145                              <2> section_of ..@yy_filename_empty, boot_parse_fn
   146                              <2> section_of count_store, count_store.maybe_0
   147                              <2> section_of loader_get_resident_address, loader_prepare_resident
   148                              <2> 
   149                              <2> 
   150                              <2>  %if _SYMBOLIC && _DUALCODE && _SYMBOLASMDUALCODE
   151                              <2> 	usesection lDEBUG_CODE2
   152                              <2>  %else
   153                              <2> 	usesection lDEBUG_CODE
   153          ------------------  <2>  note: usesection lDEBUG_CODE
   154                              <2>  %endif
   155                              <2> section_of bxcx_to_cx_paragraphs
   156                              <2> section_of zz_list_symbol.first, zz_list_symbol.subsequent
   157                              <2> section_of zz_xms_to_86mm, zz_xms_try_free, zz_xms_try_free_handle
   158                              <2> section_of zz_86mm_to_xms, zz_del_match.add_poison_entrypoint
   159                              <2> section_of zz_free_nonxms, zz_free_xms, zz_free_reset, zz_free_dos
   160                              <2> section_of zz_get_literal, zz_restore_strat, zz_save_strat
   161                              <2> section_of zz_switch_s, zz_transfer_buffer
   162                              <2> 
   163                              <2> 
   164                              <2> %if _SYMBOLIC
   165                              <2>  %if _DUALCODE && _SYMBOLICDUALCODE
   166                              <2> 	usesection lDEBUG_CODE2
   167                              <2>  %else
   168                              <2> 	usesection lDEBUG_CODE
   169                              <2>  %endif
   170                              <2> section_of shift_left_4_bxcx
   171                              <2> section_of selector_to_segment
   172                              <2> 
   173                              <2> section_of anti_normalise_pointer_with_displacement_bxcx, displaystring
   174                              <2> section_of getfarpointer.hash, getfarpointer.main, getfarpointer.str
   175                              <2> section_of move_delete_farpointer.hash, move_delete_farpointer.hash.sidi
   176                              <2> section_of move_delete_farpointer.main, move_delete_farpointer.str.sidi
   177                              <2> section_of move_insert_farpointer.hash, move_insert_farpointer.hash.sidi
   178                              <2> section_of move_insert_farpointer.main, move_insert_farpointer.main.sidi
   179                              <2> section_of move_insert_farpointer.str.sidi
   180                              <2> section_of normalise_pointer, normalise_pointer_with_displacement_bxcx
   181                              <2> section_of pointer_to_linear
   182                              <2> section_of save_slice_farpointer.hash, save_slice_farpointer.main
   183                              <2> section_of save_slice_farpointer.str
   184                              <2> section_of segment_to_selector
   185                              <2> section_of zz_insert, zz_match_symbol, zz_match_symbol.continue, zz_relocate
   186                              <2> 
   187                              <2> section_of binsearchhash, binsearchmain
   188                              <2> section_of check_second_slice
   189                              <2> section_of disp_size_hash, disp_size_main, disp_size_str
   190                              <2> section_of displayresult, getstring1, getstring2
   191                              <2> section_of increment_ss_ref_count
   192                              <2> section_of list_sym_storage_usage, str_index_to_pointer
   193                              <2> section_of zz_commit_insert, zz_compact, zz_compact_expand_check_nonxms
   194                              <2> section_of zz_compact_expand_check_xms
   195                              <2> section_of zz_delete_hash, zz_delete_main, zz_delete_main_and_its_hash
   196                              <2> section_of zz_delete_string, zz_expand, zz_expand_common
   197                              <2> section_of zz_get_symstr_length_bytes
   198                              <2> section_of zz_get_symstr_length_bytes.ssLength_in_cx
   199                              <2> section_of zz_get_symstr_length_indices
   200                              <2> section_of zz_get_symstr_length_indices.ssLength_in_cx
   201                              <2> section_of zz_hash, zz_hash.bx_init
   202                              <2> section_of zz_insert_main.linklist, zz_reloc_main, zz_reloc_str
   203                              <2> section_of zz_store_pre_str, zz_store_string, zz_store_string.hash_bx
   204                              <2> section_of zz_unlink_main_next
   205                              <2> %endif
   206                              <2> 
   207                              <2> %if _DUALCODE
   208                              <2> 	usesection lDEBUG_CODE2
   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
    32                                  [list +]
    33                                  
    34                                  %ifn _LINK
    35                                  %ifndef _MAP
    36                                  %elifempty _MAP
    37                                  %else	; defined non-empty, str or non-str
    38                                  	[map all _MAP]
    39                                  %endif
    40                                  
    41                                  %if _ONLY386
    42                                  	cpu 386
    43                                  %else
    44                                  	cpu 8086
    45                                  %endif
    46                                  
    47                                  %include "sections.mac"
    48                                  
    49                                  
    50                                  		; This is used to refer to the program image parts
    51                                  		;  that are always to be placed at a fixed position
    52                                  		;  directly behind the PSP. (These never need to be
    53                                  		;  relocated in application mode, except if the /T
    54                                  		;  switch is used.)
    55                                  %define DATAENTRYTABLESIZE (ldebug_data_entry_size 			+ asmtable1_size 			+ asmtable2_size)
    58                                  
    59                                  		; The following are offsets from the PSP segment,
    60                                  		;  in application mode. They refer to the sources
    61                                  		;  of these section images in the program image.
    62                                  		; Device driver and bootloaded mode early on will
    63                                  		;  set up ds so that ds:100h -> program image,
    64                                  		;  mimicking the application mode with a pseudo-PSP
    65                                  		;  segment address.
    66                                  		; Device driver mode will relocate everything to end
    67                                  		;  up with device shim, pseudo MCB (16 bytes), PSP
    68                                  		;  (256 bytes), data/entry, asmtables, data/stack,
    69                                  		;  message. After that the auxbuff, history buffer,
    70                                  		;  code1, code2, environment, and ext segment can be
    71                                  		;  placed. Finally a single paragraph is reserved
    72                                  		;  for an SD container MCB.
    73                                  		; For application mode, data/entry and asmtables
    74                                  		;  are not usually relocated. The original PSP is
    75                                  		;  used as is too. Behind the asmtables, the setup
    76                                  		;  is similar to device mode. The exception is that
    77                                  		;  the entire resident debugger, process and all,
    78                                  		;  can be relocated late in init, by using the /T
    79                                  		;  switch to init.
    80                                  		; Boot loaded mode will relocate everything to end
    81                                  		;  up at the top of the LMA, including the "NDEB"
    82                                  		;  image identification paragraph (always on a KiB
    83                                  		;  boundary), the pseudo PSP, and then all the
    84                                  		;  resident sections. (To fill to a KiB-aligned
    85                                  		;  size, some padding may follow at the end.)
    86                                  %define MESSAGESECTIONOFFSET (100h + DATAENTRYTABLESIZE)
    87                                  %define CODESECTIONOFFSET (MESSAGESECTIONOFFSET + messagesegment_size)
    88                                  %define INITSECTIONOFFSET (CODESECTIONOFFSET+ldebug_code_size+ldebug_code2_size)
    89                                  
    90                                  		; These targets indicate where to place the code
    91                                  		;  code sections and auxbuff when boot loaded.
    92                                  		;  This uses full segments (not truncated).
    93                                  %define BOOTCODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_size + datastack_size)
    94                                  %define BOOTCODETARGET2 (BOOTCODETARGET1+auxbuff_size)
    95                                  %define BOOTAUXTARGET1 (BOOTCODETARGET1+ldebug_code_size+ldebug_code2_size)
    96                                  %define BOOTAUXTARGET2 BOOTCODETARGET1
    97                                  %define BOOTAUXTARGET3 (BOOTAUXTARGET1+auxbuff_size)
    98                                  
    99                                  %if _BOOTLDR_DISCARD || _BOOTLDR_DISCARD_HELP
   100                                  		; If the message and/or code section is truncated
   101                                  		;  then non-boot-loaded modes have to calculate
   102                                  		;  their layouts with the truncated sizes. The
   103                                  		;  CODETARGET1 is based on MESSAGESECTIONOFFSET
   104                                  		;  because CODESECTIONOFFSET already implies the
   105                                  		;  use of the untruncated message segment.
   106                                  %define CODETARGET1 (MESSAGESECTIONOFFSET + messagesegment_nobits_truncated_size + datastack_size)
   107                                  %define CODETARGET2 (CODETARGET1+auxbuff_size)
   108                                  %define AUXTARGET1 (CODETARGET1+ldebug_code_bootldr_truncated_size+ldebug_code2_size)
   109                                  %define AUXTARGET2 CODETARGET1
   110                                  %define AUXTARGET3 (AUXTARGET1+auxbuff_size)
   111                                  %else
   112                                  		; If no section is truncated we can just directly
   113                                  		;  re-use the layouts, same as things were before
   114                                  		;  the sections were made to be truncated.
   115                                  %xdefine CODETARGET1 BOOTCODETARGET1
   116                                  %xdefine CODETARGET2 BOOTCODETARGET2
   117                                  %xdefine AUXTARGET1 BOOTAUXTARGET1
   118                                  %xdefine AUXTARGET2 BOOTAUXTARGET2
   119                                  %xdefine AUXTARGET3 BOOTAUXTARGET3
   120                                  %endif
   121                                  
   122                                  		; This calculation allows for all the sections
   123                                  		;  that are stored in the program image (the
   124                                  		;  first term) plus the data/stack section,
   125                                  		;  auxbuff twice (twice for if layout 3 needed),
   126                                  		;  and the separate history segment. After init
   127                                  		;  is relocated this high, all destinations for
   128                                  		;  the to-be resident sections can be written to.
   129                                  		; (Now also includes the environment block and
   130                                  		;  the ext code segment.)
   131                                  		; This is based on the application PSP segment.
   132                                  		; Update: This may be not large enough for the
   133                                  		;  aux and ext buffers if _INIT_MAX=0. In this
   134                                  		;  case, init may have to relocate itself a
   135                                  		;  second time later to make space for the full
   136                                  		;  buffers.
   137                                  %define APPINITTARGET (INITSECTIONOFFSET 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ app_env_size 			+ extsegment_size)
   144                                  		; The early stack goes behind the init target.
   145                                  %define APPINITSTACK_START (APPINITTARGET+init_size)
   146                                  APPINITSTACK_SIZE equ 512	; must be even
   147                                  		; This is the size of the application mode
   148                                  		;  process memory block required while still
   149                                  		;  using the init stack behind init target.
   150                                  %define APPINITSTACK_END (APPINITSTACK_START+APPINITSTACK_SIZE)
   151                                  
   152                                  BOOTINITSTACK_SIZE equ 512	; must be divisible by 16
   153                                  		; Similar to APPINITTARGET this calculates
   154                                  		;  the size needed for the maximum size resident
   155                                  		;  image once installed. The auxbuff size twice,
   156                                  		;  history segment, data/stack section, and the
   157                                  		;  INITSECTIONOFFSET are the same here. The final
   158                                  		;  +16 is for the NDEB image identification
   159                                  		;  paragraph. The KiB macros are to round up the
   160                                  		;  size to the next kibi byte boundary as we will
   161                                  		;  install by modifying the int 12h return value,
   162                                  		;  which has kibi byte granularity.
   163                                  		; (Now also includes the environment block and
   164                                  		;  the ext code segment.)
   165                                  %define BOOTDELTA	(fromkib(kib(auxbuff_size * 2 				+ historysegment_boot_size 				+ boot_env_size 				+ extsegment_boot_size 				+ datastack_size 				+ INITSECTIONOFFSET + 16)))
   171                                  
   172                                  %if _DEVICE
   173                                  		; This is the size of the shim, the pseudo MCB,
   174                                  		;  as well as the process we will create.
   175                                  %define DEVICEADJUST	(deviceshim_size + 110h)
   176                                  		; Like APPINITTARGET, except we need to add
   177                                  		;  in the device adjust for the additional things
   178                                  		;  to place before the resident image.
   179                                  		; The final 10h is for the SD container MCB space
   180                                  		;  reserved at the end of our resident allocation.
   181                                  		; Question: Is the PSP size included in the define
   182                                  		;  INITSECTIONOFFSET redundant with DEVICEADJUST?
   183                                  		;  Even if this is true it has very little negative
   184                                  		;  effects, we would simply need 256 more bytes
   185                                  		;  than would be required.
   186                                  		; Answer: No, it isn't redundant. The first PSP size
   187                                  		;  is to translate from the entrypoint ds (where
   188                                  		;  ds:100h -> program image) to the device header.
   189                                  		;  The second PSP size is for the actual PSP that is
   190                                  		;  allocated eventually.
   191                                  %define DEVICEINITTARGET (INITSECTIONOFFSET 			+ DEVICEADJUST 			+ datastack_size 			+ ext_data_nonboot_add_size 			+ auxbuff_size + auxbuff_init_size 			+ historysegment_size 			+ dev_env_size 			+ extsegment_size 			+ 10h)
   200                                  		; The minus 100h is because the target calculates
   201                                  		;  from the pseudo PSP location on entry (cs - 10h).
   202                                  		;  To check the size we can subtract this term so as
   203                                  		;  to not use more than needed.
   204                                  		; This adds the shim size as the shim exists in its
   205                                  		;  own section behind the init section. It will be
   206                                  		;  discarded at this spot after it was copied to the
   207                                  		;  resident position of the device header.
   208                                  		; No temporary stack in or behind the init section is
   209                                  		;  used because the device installer provides a
   210                                  		;  perfectly valid stack for us to use.
   211                                  %define DEVICEINITSIZE (DEVICEINITTARGET - 100h 			+ init_size 			+ deviceshim_size)
   214                                  %endif	; _DEVICE
   215                                  %endif	; _LINK
   216                                  
   217                                  
   218                                  %if _LINK
   219                                   global behind_progbits_dataentry, behind_messagesegment
   220                                   global behind_deviceshim
   221                                  	usesection lDEBUG_DATA_ENTRY
   221          ------------------       note: usesection lDEBUG_DATA_ENTRY
   222                                  	align 16, nop
   223                                  	usesection ASMTABLE1
   223          ------------------       note: usesection ASMTABLE1
   224                                  	align 16, nop
   225                                  	usesection ASMTABLE2
   225          ------------------       note: usesection ASMTABLE2
   226                                  	align 16, nop
   227                                  	usesection DATASTACKBASE
   227          ------------------       note: usesection DATASTACKBASE
   228                                  	align 16, nop
   229                                  behind_progbits_dataentry:
   230                                  	usesection MESSAGESEGMENT
   230          ------------------       note: usesection MESSAGESEGMENT
   231                                  	align 16, nop
   232                                  	usesection lDEBUG_CODE
   232          ------------------       note: usesection lDEBUG_CODE
   233                                  	align 16, nop
   234                                  behind_messagesegment:
   235                                  %ifn _MESSAGESEGMENT
   236                                  behind_messagesegment_nobits_truncated:
   237                                  %endif
   238                                  	usesection lDEBUG_CODE2
   238          ------------------       note: usesection lDEBUG_CODE2
   239                                  	align 16, nop
   240                                  behind_code:
   241                                  	usesection INIT
   241          ------------------       note: usesection INIT
   242                                  	align 16, nop
   243                                  behind_code2:
   244                                  	usesection WLEMITALIGNINITEND
   244          ------------------       note: usesection WLEMITALIGNINITEND
   245                                  behind_init:
   246                                  	usesection DEVICESHIM
   246          ------------------       note: usesection DEVICESHIM
   247                                  	align 16, nop
   248                                  	usesection WLEMITALIGNRELOCZERO
   248          ------------------       note: usesection WLEMITALIGNRELOCZERO
   249                                  behind_deviceshim:
   250                                  relocatedzero:
   251                                  
   252                                  %include "patch.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug patch area segment equates
     5                              <1> 
     6                              <1> Copyright (C) 2008-2026 E. C. Masloch
     7                              <1> 
     8                              <1> Usage of the works is permitted provided that this
     9                              <1> instrument is retained with the works, so that any entity
    10                              <1> that uses the works is notified of this instrument.
    11                              <1> 
    12                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    13                              <1> 
    14                              <1> %endif
    15                              <1> 
    16                              <1> %if _RUN2_ENTRY_SECTION
    17                              <1> patcharea_run.segment equ pspdbg
    18                              <1> %else
    19                              <1> patcharea_run.segment equ code_seg
    20                              <1> %endif
    21                              <1> patcharea_intrtn.segment equ pspdbg
    22                              <1> patcharea_pm_exc.segment equ pspdbg
   253                                  
   254                                  	usesection lDEBUG_DATA_ENTRY
   254          ------------------       note: usesection lDEBUG_DATA_ENTRY
   255 00000000 00<rep 100h>            	times 256 db 0
   256                                  ..start:
   257                                  %endif
   258                                  
   259                                  
   260                                  %if _DEVICE
   261                                  		; The final resident copy of this device header
   262                                  		;  is relocated from the shim to in front of our
   263                                  		;  PSP. Therefore, this space after the PSP can
   264                                  		;  be re-used for the newly expanded N buffer.
   265                                  		;  (Refer to N_BUFFER_END.)
   266                                  
   267                                  		; The device header is of a fixed format.
   268                                  		;  For our purposes, the 4-byte code for
   269                                  		;  each the strategy entry and the
   270                                  		;  interrupt entry is part of this format.
   271                                  		; (DOS may read the attributes or entrypoint
   272                                  		;  offsets before calling either, so the
   273                                  		;  inicomp stage needs to recreate in its
   274                                  		;  entrypoints part exactly what we have here.)
   275                                  %macro writedeviceheader 3
   276                                  	hiddenusesection %1
   277                                  %2:
   278                                  .next:
   279                                  %ifidni %1, DEVICESHIM
   280                                  	dd -1
   281                                  %else
   282                                  	fill 2, -1, jmp strict short j_zero_entrypoint
   283                                  	dw -1
   284                                  %endif
   285                                  .attributes:
   286                                  	dw 8800h			; character device, open/close supported
   287                                  		; Setting bit 800h means that opening the device
   288                                  		;  will already cause a critical error. This
   289                                  		;  discourages opening the character device.
   290                                  		;  As we never use it we want to avoid opens.
   291                                  .strategy:
   292                                  	dw .strategy_entry %3		; -> strategy entry
   293                                  .interrupt:
   294                                  	dw .interrupt_entry %3		; -> interrupt entry
   295                                  .name:
   296                                  	fill 8, 32, db "LDEBUG$$"	; character device name
   297                                  .strategy_entry:
   298                                  	fill 4, 90h, jmp %2 %+ .device_entrypoint
   299                                  .interrupt_entry:
   300                                  	fill 4, 90h, retf
   301                                  %endmacro
   302                                  
   303                                  writedeviceheader lDEBUG_DATA_ENTRY, device_header, - 100h
   276                              <1>  hiddenusesection %1
   276          ------------------  <1>  note: usesection lDEBUG_DATA_ENTRY
   277                              <1> %2:
   278                              <1> .next:
   279                              <1> %ifidni %1, DEVICESHIM
   280                              <1>  dd -1
   281                              <1> %else
   282 00000100 EB3E                <1>  fill 2, -1, jmp strict short j_zero_entrypoint
   283 00000102 FFFF                <1>  dw -1
   284                              <1> %endif
   285                              <1> .attributes:
   286 00000104 0088                <1>  dw 8800h
   287                              <1> 
   288                              <1> 
   289                              <1> 
   290                              <1> 
   291                              <1> .strategy:
   292 00000106 [1200]              <1>  dw .strategy_entry %3
   293                              <1> .interrupt:
   294 00000108 [1600]              <1>  dw .interrupt_entry %3
   295                              <1> .name:
   296 0000010A 4C44454255472424    <1>  fill 8, 32, db "LDEBUG$$"
   297                              <1> .strategy_entry:
   298 00000112 EB3690<rep 2h>      <1>  fill 4, 90h, jmp %2 %+ .device_entrypoint
   299                              <1> .interrupt_entry:
   300 00000116 CB90<rep 3h>        <1>  fill 4, 90h, retf
   304                                  .pass_lcfg:
   305 0000011A 00000000                	dd 0				; (not used yet)
   306                                  %else
   307                                  	jmp initcode_j
   308                                  %endif
   309                                  
   310                                  		; Startup codes can be discarded after one of
   311                                  		;  them is used to enter the initialisation part.
   312                                  		;  Therefore the N buffer is now extended past
   313                                  		;  these codes, refer to N_BUFFER_END.
   314                                  %if _BOOTLDR
   315 0000011E 00<rep 2h>              	align 32, db 0
   316                                   %if !_LINK && ($ - $$) != 32
   317                                    %error Wrong kernel iniload entrypoint
   318                                   %endif
   319                                   %if _LINK && ($ - $$) != 256 + 32
   320                                    %error Wrong kernel iniload entrypoint
   321                                   %endif
   322 00000120 BB[0000]                	mov bx, boot_initcode
   323                                  %endif
   324                                  
   325                                  %if _BOOTLDR || _DEVICE
   326                                  		; INP:	cs:0 => program image
   327                                  		;	INIT:bx -> init entrypoint
   328                                  device_boot_common_entrypoint:
   329 00000123 8CC8                    	mov ax, cs
   330 00000125 83E810                  	sub ax, 10h
   331 00000128 8ED8                    	mov ds, ax	; => would-be PSP before program image
   332 0000012A EB18                    	jmp @F
   333                                  %endif
   334 0000012C 00<rep 14h>             	align 64, db 0
   335                                   %if !_LINK && ($ - $$) != 64
   336                                    %error Wrong application entrypoint
   337                                   %endif
   338                                   %if _LINK && ($ - $$) != 256 + 64
   339                                    %error Wrong application entrypoint
   340                                   %endif
   341                                  
   342                                  		; INP:	cs = ds => PSP
   343                                  j_zero_entrypoint:
   344                                  initcode_j:
   345 00000140 8CC8                    	mov ax, cs
   346 00000142 31DB                    	xor bx, bx
   347                                  
   348                                  		; INP:	ds:100h = ax:100h -> program image
   349                                  		;	INIT:bx -> init entrypoint
   350                                  @@:
   351                                  %if _LINK
   352 00000144 05[0000]                	add ax, strict word relocatedzero + 0
   353                                  wlcalc word_segrel_INIT, equ $ - 2
   354                                  %else
   355                                  	add ax, paras(INITSECTIONOFFSET)
   356                                  			; => original INIT section in program image
   357                                  %endif
   358 00000147 50                      	push ax
   359 00000148 53                      	push bx
   360 00000149 CB                      	retf		; dispatch to INIT code
   361                                  
   362                                  
   363                                  %if _DEVICE
   364                                  		; INP:	es:bx -> device request header
   365                                  		;	ss:sp -> a DOS stack, far return address to DOS
   366                                  		;	cs:0 -> our start image
   367                                  		; OUT:	bx = offset of init function in INIT segment
   368                                  		;	ss:sp -> bx, fl, ds, ax, far return address
   369                                  device_header.device_entrypoint:
   370 0000014A 26807F0200              	cmp byte [es:bx + 2], 0		; command code 0 (init) ?
   371 0000014F 7414                    	je @F
   372                                  
   373 00000151 26C747030001            	mov word [es:bx + 3], 0100h	; no error, done
   374 00000157 26807F020E              	cmp byte [es:bx + 2], 0Eh	; command code 0Eh (close) ?
   375 0000015C 7406                    	je .retf			; yes, accept it -->
   376 0000015E 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
   377 00000164 CB                      .retf:	retf
   378                                  
   379                                  @@:
   380 00000165 50                      	push ax
   381 00000166 1E                      	push ds
   382 00000167 9C                      	pushf
   383 00000168 53                      	push bx
   384 00000169 BB[0000]                	mov bx, device_initcode
   385 0000016C EBB5                    	jmp device_boot_common_entrypoint
   386                                  
   387                                  
   388                                  writedeviceheader DEVICESHIM, shim_device_header, - 0
   276                              <1>  hiddenusesection %1
   276          ------------------  <1>  note: usesection DEVICESHIM
   277                              <1> %2:
   278                              <1> .next:
   279                              <1> %ifidni %1, DEVICESHIM
   280 00000000 FFFFFFFF            <1>  dd -1
   281                              <1> %else
   282                              <1>  fill 2, -1, jmp strict short j_zero_entrypoint
   283                              <1>  dw -1
   284                              <1> %endif
   285                              <1> .attributes:
   286 00000004 0088                <1>  dw 8800h
   287                              <1> 
   288                              <1> 
   289                              <1> 
   290                              <1> 
   291                              <1> .strategy:
   292 00000006 [1200]              <1>  dw .strategy_entry %3
   293                              <1> .interrupt:
   294 00000008 [1600]              <1>  dw .interrupt_entry %3
   295                              <1> .name:
   296 0000000A 4C44454255472424    <1>  fill 8, 32, db "LDEBUG$$"
   297                              <1> .strategy_entry:
   298 00000012 EB0690<rep 2h>      <1>  fill 4, 90h, jmp %2 %+ .device_entrypoint
   299                              <1> .interrupt_entry:
   300 00000016 CB90<rep 3h>        <1>  fill 4, 90h, retf
   389                                  shim_device_header.device_entrypoint:
   390 0000001A 26C747030001            	mov word [es:bx + 3], 0100h	; no error, done
   391 00000020 26807F020E              	cmp byte [es:bx + 2], 0Eh	; command code 0Eh (close) ?
   392 00000025 7406                    	je .retf			; yes, accept it -->
   393 00000027 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
   394 0000002D CB                      .retf:	retf
   395                                  
   396 0000002E 90<rep 2h>              	align 16
   397                                  deviceshim_size	equ $ - $$
   398                                  	endarea deviceshim, 1
   399                                  
   400                                  
   401                                  	usesection lDEBUG_DATA_ENTRY
   401          ------------------       note: usesection lDEBUG_DATA_ENTRY
   402                                  %else
   403                                  deviceshim_size	equ 0
   404                                  %endif
   405                                  
   406                                  
   407                                  	align 2, db 0
   408                                  N_BUFFER_END equ $		; end of N buffer (starts in PSP at 80h)
   409                                  
   410 0000016E [0000][0000][0000]-     cmdlist:	repeatdw aa,bb,cc,ddd,ee,ff,gg,hh,ii,error,kk,ll,mm,nn,oo
   410 00000174 [0000][0000][0000]-
   410 0000017A [0000][0000][0000]-
   410 00000180 [D211][C508][0000]-
   410 00000186 [0000][A608][0000] 
   411 0000018C [0000][F20A][0000]-     		repeatdw pp,qq,rr,sss,tt,uu,vv,ww,xx,yy
   411 00000192 [0000][0000][0000]-
   411 00000198 [0000][0000][D211]-
   411 0000019E [0000]             
   412                                  %if _SYMBOLIC
   413                                  		dw zz
   414                                  %endif
   415                                  
   416                                  %if _LOADER
   417                                  aa equ error
   418                                  cc equ error
   419                                  kk equ error
   420                                  ll equ error
   421                                  nn equ error
   422                                  pp equ error
   423                                  tt equ error
   424                                  ww equ error
   425                                  %endif
   426                                  
   427                                  
   428                                  %ifn _LINK
   429                                  %include "options.mac"
   430                                  %endif
   431                                  
   432                                  	align 4, db 0
   433                                  				; options, startoptions and internalflags
   434                                  				; have to be consecutive
   435 000001A0 00000000                options:	dd DEFAULTOPTIONS ; run-time options
   436 000001A4 10410080                options2:	dd DEFAULTOPTIONS2
   437 000001A8 0F000060                options3:	dd DEFAULTOPTIONS3
   438 000001AC 02000000                options4:	dd DEFAULTOPTIONS4
   439 000001B0 00000000                options5:	dd 0
   440 000001B4 00000100                options6:	dd DEFAULTOPTIONS6
   441 000001B8 00200000                options7:	dd DEFAULTOPTIONS7
   442                                  	; options, options2, options3, options4, options5, options6, options7
   443                                  	;  are each assumed to be dwords
   444                                  	;  and all consecutive in expr.asm isvariable?
   445                                  
   446 000001BC 00000000                startoptions:	dd DEFAULTOPTIONS ; options as determined during startup; read-only for user
   447 000001C0 10410080                startoptions2:	dd DEFAULTOPTIONS2
   448 000001C4 0F000060                startoptions3:	dd DEFAULTOPTIONS3
   449 000001C8 02000000                startoptions4:	dd DEFAULTOPTIONS4
   450 000001CC 00000000                startoptions5:	dd 0
   451 000001D0 00000100                startoptions6:	dd DEFAULTOPTIONS6
   452 000001D4 00200000                startoptions7:	dd DEFAULTOPTIONS7
   453                                  	; startoptions, startoptions2, startoptions3, startoptions4,
   454                                  	;  startoptions5, startoptions6
   455                                  	;  are each assumed
   456                                  	;  to be dwords and all consecutive in expr.asm isvariable?
   457                                  
   458 000001D8 F8308000                internalflags:	dd attachedterm|pagedcommand|notstdinput|inputfile|notstdoutput|outputfile|debuggeeA20|debuggerA20
   459                                  				; flags only modified by DEBUG itself
   460                                  internalflags2:
   461                                  %if _SYMBOLIC
   462                                  		dd dif2_sym_req_xms | dif2_sym_req_86mm
   463                                  %else
   464 000001DC 00000000                		dd 0
   465                                  %endif
   466 000001E0 80040000                internalflags3:	dd dif3_partition_changed | dif3_at_line_end
   467 000001E4 00000000                internalflags4:	dd 0
   468 000001E8 00000000                internalflags5:	dd 0
   469                                  internalflags6:
   470                                  %if _MCP
   471                                   %assign DIF6MCP dif6_mcp
   472                                  %else
   473                                   %assign DIF6MCP 0
   474                                  %endif
   475                                  %if (_DEBUG && ! _DEBUG_COND) || _LOADER
   476                                  		dd DIF6MCP | dif6_debug_mode	; always indicate debuggable
   477                                  %else
   478 000001EC 00000000                		dd DIF6MCP
   479                                  %endif
   480 000001F0 00000000                internalflags7:	dd 0
   481                                  	; internalflags, internalflags2, internalflags3, internalflags4,
   482                                  	;  internalflags5, internalflags6, internalflags7
   483                                  	;  are each assumed
   484                                  	;  to be dwords and all consecutive in expr.asm isvariable?
   485                                  
   486                                  %if !_LOADER
   487 000001F4 07F00000                asm_options:	dd DEFAULTASMOPTIONS
   488                                  asm_startoptions:
   489 000001F8 07F00000                		dd DEFAULTASMOPTIONS
   490                                  
   491 000001FC 00000000                gg_first_cseip_linear:	dd 0
   492 00000200 00000000                gg_next_cseip_linear:	dd 0
   493 00000204 00000000                tpg_possible_breakpoint:dd 0
   494 00000208 [0000]                  gg_deferred_message:	dw msg.empty_message
   495                                  bb_deferred_message_in_lineout_behind:
   496 0000020A 0000                    			dw 0
   497                                  		align 4, db 0
   498 0000020C 00<rep 6h>              tpg_proceed_bp:		times BPSIZE db 0
   499                                  %if _DEBUG1
   500                                  		align 2, db 0
   501                                  test_records_Readmem:		times 6 * 16 db 0
   502                                  test_records_Writemem:		times 6 * 16 db 0
   503                                  test_records_getLinear:		times 6 * 16 db 0
   504                                  test_records_getSegmented:	times 6 * 16 db 0
   505                                  
   506                                  test_readmem_value:		db 0
   507                                  %endif
   508 00000212 00                      pp_instruction:		db 0
   509                                  %if _RH
   510 00000213 00                      skip_rh:	db 0
   511                                  %endif
   512                                  %if _RH || _SWHILEBUFFER || _RECMDWHILEBUFFER || _EXTENSIONS
   513 00000214 00                      in_re:		db 0
   514                                  %endif
   515 00000215 00<rep 3h>              		align 4, db 0
   516 00000218 00000000                pp_operand:		dd 0
   517                                  %if _PM && _DEBUG_PM_ENTRY
   518                                  debug_pm_entry_total:	dd 0
   519                                  debug_pm_entry_esph:	dd 0
   520                                  debug_pm_entry_b:	dd 0
   521                                  %endif
   522                                  %endif
   523                                  %if _LOADER
   524                                  currentposition:	db 2	; 0 = bottom, 1 = top, 2 = hidden
   525                                  			db 0
   526                                  %endif
   527                                  		align 2, db 0
   528 0000021C 0000                    code_seg:	dw 0		; LOADER-relocate
   529                                  %if _PM
   530                                  code_sel:	dw 0
   531                                  %endif
   532                                  %if _DUALCODE
   533                                  code2_seg:	dw 0
   534                                   %if _PM
   535                                  code2_sel:	dw 0
   536                                   %endif
   537                                  %endif
   538                                  %if _IMMASM
   539 0000021E 0000                    immseg:		dw 0
   540                                  %endif
   541                                  %if _MESSAGESEGMENT
   542                                   %if _ELDLINKINFO
   543 00000220 [0000]                  linkinfoaddress:dw linkinfo
   544                                   %endif
   545 00000222 0000                    messageseg:	dw 0		; LOADER-relocate
   546                                   %if _PM
   547                                  messagesel:	dw 0
   548                                   %endif
   549                                  %endif
   550                                  %if _EXTENSIONS
   551 00000224 0000                    extseg:		dw 0		; LOADER-relocate
   552                                   %if _PM
   553                                  extcssel:	dw 0
   554                                   %if extseg + 2 != extcssel
   555                                    %error code_ret_to_ext expects extcssel after extseg
   556                                   %endif
   557                                  extdssel:	dw 0
   558                                   %else
   559                                  extcssel equ extseg
   560                                  extdssel equ extseg
   561                                   %endif
   562                                  %endif
   563                                  %if _APP_ENV_SIZE || _DEV_ENV_SIZE || _BOOT_ENV_SIZE
   564 00000226 0000                    envseg:		dw 0		; (includes pseudo-MCB)	; LOADER-relocate
   565 00000228 0000                    env_size:	dw 0
   566                                  %endif
   567                                  
   568                                  %if _LINK
   569 0000022A [1050]                  entryseg_size:		dw end_of_datastack
   570 0000022C [0000]                  code_size:		dw behind_code wrt lDEBUG_CODE	; may truncate
   571                                  %if _DUALCODE
   572                                  code2_size:		dw behind_code2 wrt lDEBUG_CODE2
   573                                  %endif
   574                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
   575 0000022E 0020                    historyseg_size:	dw historysegment_boot_size
   576                                  %endif
   577                                  %if _MESSAGESEGMENT
   578 00000230 [0000]                  messageseg_size:	dw behind_messagesegment_nobits wrt MESSAGESEGMENT
   579                                  						; may truncate
   580                                  %endif
   581                                  %if _HELP_COMPRESSED && _BOOTLDR_DISCARD_HELP
   582                                  indirect_hshrink_message_buffer:
   583 00000232 [0000]                  			dw nontruncated_hshrink_message_buffer
   584                                  %endif
   585                                  %else
   586                                  entryseg_size:		dw 100h + DATAENTRYTABLESIZE + datastack_size
   587                                  code_size:		dw ldebug_code_size	; may truncate
   588                                  %if _DUALCODE
   589                                  code2_size:		dw ldebug_code2_size
   590                                  %endif
   591                                  %if _HISTORY_SEPARATE_FIXED && _HISTORY
   592                                  historyseg_size:	dw historysegment_boot_size
   593                                  %endif
   594                                  %if _MESSAGESEGMENT
   595                                  messageseg_size:	dw messagesegment_nobits_size	; may truncate
   596                                  %endif
   597                                  %if _HELP_COMPRESSED && _BOOTLDR_DISCARD_HELP
   598                                  indirect_hshrink_message_buffer:
   599                                  			dw nontruncated_hshrink_message_buffer
   600                                  %endif
   601                                  %endif
   602                                  
   603                                  %if _EXTENSIONS
   604 00000234 0020                    extseg_size:		dw extsegment_size
   605 00000236 0000                    extseg_used:		dw 0
   606 00000238 [1010]                  extdata:		dw ext_data_area
   607 0000023A 0040                    extdata_size:		dw ext_data_area.size
   608 0000023C 0000                    extdata_used:		dw 0
   609 0000023E 0000                    ext_command_handler:	dw 0
   610 00000240 0000                    ext_preprocess_handler:	dw 0
   611 00000242 0000                    ext_inject_handler:	dw 0
   612                                  %if !_LOADER
   613 00000244 0000                    ext_aa_before_getline_handler:	dw 0
   614 00000246 0000                    ext_aa_inject_handler:		dw 0
   615 00000248 0000                    ext_aa_after_getline_handler:	dw 0
   616                                  %endif
   617 0000024A 0000                    ext_puts_handler:	dw 0
   618 0000024C 0000                    ext_puts_copyoutput_handler:	dw 0
   619                                  %if _EXT_PUTS_GETLINE
   620 0000024E 0000                    ext_puts_getline_handler:	dw 0
   621                                  %endif
   622                                  %if _CATCHINT2D
   623 00000250 0000                    ext_amis_handler:	dw 0
   624                                  %endif
   625                                  %if _EXT_PUTS_GETLINE
   626 00000252 00                      in_getinput:		db 0
   627 00000253 00                      			db 0	; reserved, zeroed in cmd3
   628                                  %endif
   629 00000254 0000                    pm_2_86m_0:		dw 0	; for fast, fl preserving dispatch
   630                                  
   631                                  extcall_table:
   632                                  .ret:
   633 00000256 [E413]                  	dw entry_ret_to_ext
   634                                   %if _PM
   635                                  	dw 0
   636                                   %endif
   637 00000258 [9E07]                  	dw code_ret_to_ext
   638                                   %if _PM
   639                                  	dw 0
   640                                   %endif
   641                                   %if _DUALCODE
   642                                  	dw code2_ret_to_ext
   643                                    %if _PM
   644                                  	dw 0
   645                                    %endif
   646                                   %endif
   647                                  
   648                                  .segsel:
   649 0000025A [4E0C]                  	dw pspdbg
   650                                   %if _PM
   651                                  	dw cssel
   652                                   %endif
   653 0000025C [1C02]                  	dw code_seg
   654                                   %if _PM
   655                                  	dw code_sel
   656                                   %endif
   657                                   %if _DUALCODE
   658                                  	dw code2_seg
   659                                    %if _PM
   660                                  	dw code2_sel
   661                                    %endif
   662                                   %endif
   663                                  %endif
   664 0000025E 0000                    alloc_size:		dw 0
   665 00000260 0000                    alloc_seg:		dw 0	; LOADER-relocate
   666                                  %if !_LOADER
   667 00000262 0000                    next_reserved_segment:	dw 0
   668 00000264 0000                    alloc_size_not_reserved:dw 0
   669 00000266 0000                    reserved_address:	dw 0
   670                                  %endif
   671                                  
   672 00000268 0D                      		db 13
   673 00000269 0D<rep 7h>              		align 16, db 13	; insure the cmdline_buffer is prefixed by CR
   674                                  cmdline_buffer:
   675                                  .size:		equ _RC_BUFFER_SIZE
   676 00000270 00<rep 100h>            		times .size db 0
   677                                  .end:
   678 00000370 [7002]                  .position:	dw cmdline_buffer
   679                                  
   680                                  %if !_LOADER
   681 00000372 0D                      		db 13
   682 00000373 0D                      		align 2, db 13	; insure the re_buffer is prefixed by CR
   683                                  re_buffer:
   684                                  .size:		equ _RE_BUFFER_SIZE
   685 00000374 405200<rep 7FEh>        		fill .size,0,db "@R"
   686                                  .end:
   687 00000B74 [7403]                  .position:	dw re_buffer
   688                                  
   689 00000B76 00<rep 2h>              		align 4, db 0
   690 00000B78 00000000                re_count:	dd 0
   691 00000B7C 00010000                re_limit:	dd 256
   692                                  %endif
   693                                  		align 4, db 0
   694 00000B80 00000000                rc_count:	dd 0
   695 00000B84 00100000                rc_limit:	dd 4096
   696                                  
   697                                  		align 2, db 0
   698 00000B88 0000                    cmd3_set_options:		dw 0
   699                                  %if _PM
   700                                  auxbuff_switchbuffer_size:	dw 0
   701                                  %endif
   702 00000B8A 00<rep 2h>              auxbuff_segorsel:segonlyaddress		; LOADER-relocate
   703                                  %if !_LOADER
   704                                  auxbuff_behind_last_silent:
   705 00000B8C 0000                    		dw 0		; -> behind last silent buffer entry
   706                                  %if _RH
   707                                  auxbuff_start_silent:
   708 00000B8E 0000                    		dw 0
   709                                  auxbuff_amount_silent:
   710 00000B90 0000                    		dw 0
   711                                  %endif
   712                                  %endif
   713                                  auxbuff_current_size:
   714 00000B92 1020                    		dw auxbuff_size
   715                                  %if _ELDLINKINFO || _AUXBUFFSIZE != _AUXBUFFMAXSIZE
   716                                  auxbuff_current_size_minus_24:
   717 00000B94 F81F                    		dw auxbuff_size - 24
   718                                  %endif
   719                                  
   720                                  %if !_LOADER
   721                                  tt_silent_mode_number:
   722 00000B96 0000                    		dw 0		; if non-zero: maximum amount of dumps
   723                                  				;  displayed after T/TP/P while silent
   724                                  %endif
   725                                  %if _SYMBOLIC
   726                                  created_psp:	dw 0
   727                                  created_size:	dw 0
   728                                  %endif
   729                                  %if _CONFIG
   730 00000B98 0000                    yy_boot_attempt_open_stack:	dw 0
   731 00000B9A 0000                    yy_boot_attempt_open_pathname:	dw 0
   732                                  %endif
   733                                  
   734                                  %if _INPUT_FILE_HANDLES
   735 00000B9C 90<rep 4h>              		align INPUTFILEHANDLE_size
   736                                  input_file_handles:
   737 00000BA0 FF<rep 80h>             		times _INPUT_FILE_HANDLES * INPUTFILEHANDLE_size db -1
   738 00000C20 0000                    .active:	dw 0
   739 00000C22 0000                    .to_close:	dw 0
   740                                  %endif
   741                                  	align 2, db 0
   742 00000C24 0142                    indos_remember_seek_function:	dw 4201h
   743 00000C26 FFFF                    indos_remember_seek_handle:	dw -1
   744                                  	align 4, db 0
   745 00000C28 00000000                indos_remember_seek_offset:	dd 0
   746                                  %if _INPUT_FILE_BOOT
   747                                  	align 4, db 0
   748 00000C2C 00000000                boot_remember_seek_offset:	dd 0
   749                                  	align 2, db 0
   750 00000C30 FFFF                    boot_remember_seek_handle:	dw -1
   751                                  %endif
   752                                   %if _EXTENSIONS
   753                                  	alignb 2
   754 00000C32 FFFF                    ext_handle:	dw -1
   755                                   %endif
   756                                  
   757 00000C34 00                      charcounter:	db 0		; used by raw output to handle tab
   758 00000C35 00                      linecounter:	db 0		; used by paging in puts
   759 00000C36 00<rep 2h>              	align 4, db 0
   760 00000C38 [1010]                  savesp:		dw stack_end	; saved stack pointer
   761 00000C3A 0000                    		dw 0		; 0 to set high word of esp
   762                                  %if !_LOADER
   763 00000C3C 0000                    re_sp:		dw 0
   764                                  %endif
   765 00000C3E [0000]                  errret:		dw cmd3		; return here if error
   766 00000C40 [0012]                  throwret:	dw errhandler	; return here if error - priority, no display
   767 00000C42 [1010]                  throwsp:	dw stack_end	; stack pointer set before jumping to throwret
   768 00000C44 0000                    run_sp:		dw 0		; stack pointer when running
   769 00000C46 0000                    		dw 0		; (zero for esph)
   770 00000C48 0000                    run_sp_reserve:	dw 0		; additional space to reserve between the
   771                                  				;  near return address of run and the run_sp
   772 00000C4A 4000                    spadjust:	dw 40h 		; adjust sp by this amount for save
   773                                  %if _SYMBOLIC
   774                                  stack_low_address:
   775                                  		dw str_buffer	; low end of stack, default = str_buffer
   776                                  %endif
   777                                  
   778                                  %if !_LOADER
   779 00000C4C 0000                    pspdbe:		dw 0		; debuggee's PSP (86M segment)
   780                                  				;  unless DIF&attachedterm or bootloaded
   781                                  %endif
   782                                  %ifn _MESSAGESEGMENT
   783                                   %if _ELDLINKINFO
   784                                  linkinfoaddress:dw linkinfo
   785                                   %endif
   786                                  %endif
   787 00000C4E 0000                    pspdbg:		dw 0		; debugger's PSP (86M segment)	; LOADER-relocate
   788                                  
   789                                  %if _LINK
   790                                   %ifn _PM
   791                                  dssel equ pspdbg
   792                                   %endif
   793                                  %endif
   794                                  
   795                                  %if !_LOADER
   796                                  	align 4, db 0
   797 00000C50 0000000000000000        run2324:	dd 0,0		; debuggee's interrupt vectors 23h and 24h (both modes)
   798                                  %if _PM
   799                                  		dd 0
   800                                  dbg2324:	dw i23pm, i24pm
   801                                  %endif
   802                                  %if _VDD
   803 00000C58 FFFF                    hVdd:		dw -1		; NTVDM VDD handle
   804                                  %endif
   805 00000C5A 00<rep 2h>              	align 4, db 0
   806 00000C5C 0000000000000000        sav2324:	dd 0,0		; debugger's interrupt vectors 23h and 24h (real-mode only)
   807 00000C64 00                      hakstat:	db 0		; whether we have hacked the vectors or not
   808                                  %if _MS_0RANGE_COMPAT
   809 00000C65 00                      getrange_is_uu:	db 0
   810                                  %endif
   811 00000C66 00<rep 2h>              	align 4, db 0
   812 00000C68 00000000                psp22:		dd 0		; original terminate address from our PSP
   813 00000C6C 0000                    parent:		dw 0		; original parent process from our PSP (must follow psp22)
   814                                  %if _MCB || _INT || _EXTENSIONS
   815 00000C6E FFFF                    firstmcb:	dw -1		; start of MCB chain (always segment)
   816 00000C70 FFFF                    firstumcb:	dw -1
   817                                  %endif
   818 00000C72 00<rep 4h>              pInDOS:		segofs16address	; far16 address of InDOS flag (bimodal)
   819                                  %if _USESDA
   820 00000C76 FFFFFFFF                pSDA:		segofs16address minusone
   821                                  				; far16 address of SDA (bimodal)
   822                                  %endif
   823                                  %endif
   824 00000C7A 00                      machine:	db 0		; type of processor for assembler and disassembler (1..6)
   825 00000C7B 00                      has_87:		db 0		; if there is a math coprocessor present
   826 00000C7C 00                      mach_87:	db 0		; type of coprocessor present
   827 00000C7D 00                      encodedmach87:	db 0		; C0 = no coproceasor, C = coprocessor present,
   828                                  				;  C2 = 287 present on a 386
   829                                  %if _MMXSUPP
   830 00000C7E 00                      has_mmx:	db 0
   831                                  %endif
   832                                  %if _VXCHG
   833                                   %ifn _VXCHGBIOS
   834 00000C7F 00                      		align 4, db 0
   835 00000C80 00000000                xmsdrv:	dd 0		; XMM driver address, obtained thru int 2F, ax=4310h
   836                                  xmsmove:istruc XMSM	; XMS block move struct, used to save/restore screens
   837 00000C84 00<rep 10h>             	iend
   838                                   %endif
   839                                  align 2, db 0
   840 00000C94 0000                    csrpos:	dw 0		; cursor position of currently inactive screen
   841 00000C96 00                      vrows:	db 0		; current rows; to see if debuggee changed video mode
   842                                  %endif
   843                                  %if _ALTVID		; exchange some video BIOS data fields for option /2.
   844 00000C97 0000                    oldcsrpos:	dw 0	; cursor position
   845 00000C99 0000                    oldcrtp:	dw 0	; CRTC port
   846 00000C9B 5000                    oldcols:	dw 80	; columns
   847                                  oldmr:	; label word
   848 00000C9D 00                      oldmode:	db 0	; video mode
   849 00000C9E 18                      oldrows:	db 24	; rows - 1
   850                                  %endif
   851 00000C9F 01                      bInDbg:		db 1		; 1=debugger is running
   852 00000CA0 0A                      notatty:	db 10		; if standard input is from a file
   853                                  				; this is also used for a linebreak processing hack
   854 00000CA1 00                      vpage:		db 0		; video page the debugger is to use for BIOS output
   855                                  %if _MCLOPT
   856                                  master_pic_base:db _MCLOPT_DEFAULT
   857                                  %endif
   858 00000CA2 00                      switchar:	db 0		; switch character
   859 00000CA3 20                      swch1:		db ' '		; switch character if it's a slash
   860                                  	align 2, db 0
   861                                  dd_default_length:
   862 00000CA4 8000                    		dw 80h
   863                                  dd_default_lines:
   864 00000CA6 0000                    		dw 0
   865                                  %if !_LOADER
   866                                  uu_default_length:
   867 00000CA8 2000                    		dw 20h
   868                                  uu_default_lines:
   869 00000CAA 0000                    		dw 0
   870                                  %endif
   871 00000CAC 0000                    promptlen:	dw 0		; length of prompt
   872 00000CAE [1200]                  bufnext:	dw line_in+2	; address of next available character
   873 00000CB0 [1200]                  bufend:		dw line_in+2	; address + 1 of last valid character
   874                                  %if _EXTENSIONS
   875                                  indirect_array_errfix:
   876 00000CB2 0000                    		dw 0		; -> errfix.eld's array, 0 if none installed
   877                                  %endif
   878 00000CB4 0000                    rc:		dw 0
   879 00000CB6 0000                    priorrc:	dw 0
   880 00000CB8 0000                    erc:		dw 0
   881                                  %if _HISTORY
   882                                  history:
   883                                   %if _HISTORY_SEPARATE_FIXED
   884 00000CBA 00<rep 2h>              .segorsel:	segonlyaddress	; LOADER-relocate
   885 00000CBC FE1F                    .first:		dw historysegment_boot_size - 2
   886 00000CBE FE1F                    .last:		dw historysegment_boot_size - 2
   887                                   %else
   888                                  .first:		dw historybuffer.end - 2
   889                                  .last:		dw historybuffer.end - 2
   890                                   %endif
   891                                  %endif
   892                                  
   893                                  var_addr_entries:
   894                                  %if !_LOADER
   895 00000CC0 00<rep 6h>              a_addr:		segmentedaddress; address for next A command
   896                                  %endif
   897 00000CC6 00<rep 6h>              d_addr:		segmentedaddress; address for next D command; must follow a_addr
   898                                  %if !_LOADER
   899 00000CCC 00<rep 6h>              behind_r_u_addr:segmentedaddress; address behind R's disassembly
   900 00000CD2 00<rep 6h>              u_addr:		segmentedaddress; address for next U command; must follow d_addr
   901                                  %endif
   902 00000CD8 00<rep 6h>              e_addr:		segmentedaddress; address for current/next E command
   903                                  %if _DSTRINGS
   904 00000CDE 00<rep 6h>              dz_addr:	segmentedaddress; address for next ASCIZ string
   905 00000CE4 00<rep 6h>              dcpm_addr:	segmentedaddress; address for next $-terminated string
   906 00000CEA 00<rep 6h>              dcount_addr:	segmentedaddress; address for next byte-counted string
   907 00000CF0 00<rep 6h>              dwcount_addr:	segmentedaddress; address for next word-counted string
   908                                  %endif
   909                                  var_addr_entries.amount equ ($ - var_addr_entries) / SEGADR_size
   910                                  %if _DX
   911                                  x_addr:		dd 0		; (phys) address for next DX command
   912                                  %endif
   913                                  %if _DSTRINGS
   914 00000CF6 00                      dstringtype:	db 0		; FFh byte-counted, FEh word-counted, else terminator byte
   915 00000CF7 00                      	align 2, db 0
   916 00000CF8 [DE0C]                  dstringaddr:	dw dz_addr	; -> address of last string
   917                                  %endif
   918                                  %if _INT
   919 00000CFA 00<rep 2h>              	align 4, db 0
   920 00000CFC 00000000                intaddress:	dd 0
   921                                  lastint_is_86m_and_mcb:
   922 00000D00 0000                    		dw 0
   923 00000D02 00                      lastint:	db 0
   924                                  %endif
   925                                  %if !_LOADER
   926 00000D03 00                      	align 4, db 0
   927                                  search_results:
   928                                  %if _PM
   929                                  		times 6 * search_results_amount db 0
   930                                  %else
   931 00000D04 00<rep 40h>             		times 4 * search_results_amount db 0
   932                                  %endif
   933                                  	align 4, db 0
   934 00000D44 00000000                sscounter:	dd 0
   935 00000D48 00                      eqflag:		db 0		; flag indicating presence of `=' operand
   936 00000D49 00                      	align 2, db 0
   937 00000D4A 000000000000            eqladdr:	dw 0,0,0	; address of `=' operand in G, P and T command
   938                                  	align 2, db 0
   939 00000D50 0000                    run_int:	dw 0		; interrupt type that stopped the running
   940                                  %endif
   941 00000D52 [8805]                  lastcmd:	dw dmycmd
   942                                  %if _EXTENSIONS
   943                                  lastcmd_transfer_ext_address:
   944 00000D54 0000                    		dw 0
   945                                  near_transfer_ext_address:
   946 00000D56 0000                    		dw 0
   947                                  %endif
   948                                  %if !_LOADER
   949 00000D58 00                      fileext:	db 0		; file extension (0 if no file name)
   950                                  %endif
   951                                  
   952 00000D59 00<rep 3h>              	align 4, db 0
   953 00000D5C 00000000                mmxbuff:	dd 0		; buffer with a (read-only) part of MMX register
   954                                  				; for access from within expressions
   955                                  %if _CATCHINT08
   956 00000D60 0000                    intr8_counter:	dw 0
   957 00000D62 5A00                    intr8_limit:	dw 18 * 5	; ca 5 seconds
   958                                  %endif
   959                                  %if !_LOADER
   960 00000D64 00                      maxmachinetype:	db 0
   961                                  %endif
   962                                  serial_rows:
   963 00000D65 18                      		db 24
   964                                  serial_columns:
   965 00000D66 50                      		db 80
   966                                  serial_keep_timeout:
   967 00000D67 0F                      		db 15
   968                                  %if _USE_TX_FIFO
   969                                  serial_fifo_size:
   970 00000D68 10                      		db _BI_TX_FIFO_SIZE
   971                                  			; size of built-in TX fifo (1 is as if no FIFO)
   972                                  %endif
   973 00000D69 00                      serial_flags:	db 0	; flags in options.mac
   974                                  
   975 00000D6A 0B                      serial_var_intnum:	db _INTNUM
   976 00000D6B 03                      serial_var_params:	db _UART_PARAMS
   977 00000D6C 00                      serial_var_fifo:	db _UART_FIFO
   978 00000D6D 00                      	align 2, db 0
   979 00000D6E F802                    serial_var_baseport:	dw _UART_BASE
   980 00000D70 0C00                    serial_var_dl:		dw _UART_RATE
   981 00000D72 0800                    serial_var_irqmask:	dw _OFFMASK
   982                                  
   983 00000D74 01                      io_rows:	db 1
   984 00000D75 01                      io_columns:	db 1
   985                                  	align 2, db 0
   986                                  %if _40COLUMNS
   987 00000D76 0000                    io_columns_getline:	dw 0			; byte variable zero-extended
   988                                  %endif
   989 00000D78 0000                    io_start_buffer:	dw 0
   990 00000D7A 0000                    io_end_buffer:		dw 0
   991 00000D7C FF00                    io_levels:		dw 255
   992 00000D7E 0300                    io_flags:		dw DEFAULTIOFLAGS
   993                                  iof_extra_iol_for_tpg_re:	equ 1
   994                                  iof_extra_iol_for_rc:		equ 2
   995                                  DEFAULTIOFLAGS equ iof_extra_iol_for_tpg_re | iof_extra_iol_for_rc
   996                                  
   997                                  	align 2, db 0
   998 00000D80 0000                    getline_timer_count:	dw 0
   999 00000D82 0000                    getline_timer_last:	dw 0
  1000 00000D84 [8805]                  getline_timer_func:	dw dmycmd
  1001                                  
  1002                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  1003                                  	align 2, db 0
  1004 00000D86 0000                    if_exists_then_address:	dw 0
  1005 00000D88 0000                    if_exists_si:		dw 0
  1006 00000D8A 0000                    if_exists_sp:		dw 0
  1007 00000D8C 0000                    if_exists_length:	dw 0
  1008                                  %endif
  1009                                  
  1010                                  	align 2, db 0
  1011                                  terminator_in_line_in:
  1012 00000D8E 0000                    .offset:		dw 0
  1013 00000D90 00                      .value:			db 0
  1014                                  
  1015                                  %if !_LOADER
  1016 00000D91 00                      qqtermcode:		db 0
  1017                                  	align 2, db 0
  1018 00000D92 0000                    device_mcb_paragraphs:	dw 0
  1019 00000D94 00000000                device_header_address:	dd 0
  1020                                  %endif
  1021                                  
  1022                                  	align 2, db 0
  1023                                  inttab_optional:
  1024                                  .:
  1025                                  serial_installed_intnum: equ $
  1026 00000D98 0001                    	dw 100h
  1027 00000D9A [0000]                  	dw serial_interrupt_handler
  1028 00000D9C 0100                    	dw dif4_int_serial_hooked
  1029                                  %if _LOADER
  1030                                  	dw 118h
  1031                                  	dw intr_loader_18
  1032                                  	dw dif4_int_18_hooked
  1033                                  	dw 119h
  1034                                  	dw intr_loader_19
  1035                                  	dw dif4_int_19_hooked
  1036                                  %endif
  1037                                  %if _PM
  1038                                  	dw 12Fh
  1039                                  	dw debug2F
  1040                                  	dw dif4_int_2F_hooked
  1041                                  %endif
  1042                                  %if _CATCHINT08
  1043 00000D9E 0801                    	dw 108h
  1044 00000DA0 [0000]                  	dw intr8
  1045 00000DA2 0400                    	dw dif4_int_08_hooked
  1046                                  %endif
  1047                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  1048 00000DA4 0D01                    	dw 10Dh
  1049 00000DA6 [0000]                  	dw intr0D
  1050 00000DA8 1000                    	dw dif4_int_0D_hooked
  1051                                  %endif
  1052                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  1053 00000DAA 0C01                    	dw 10Ch
  1054 00000DAC [0000]                  	dw intr0C
  1055 00000DAE 2000                    	dw dif4_int_0C_hooked
  1056                                  %endif
  1057                                  .amount: equ ($ - .) / 6
  1058 00000DB0 0000                    	dw 0
  1059                                  
  1060                                  
  1061                                  amisintr_offset:
  1062 00000DB2 [C00D]                  	dw inttab
  1063                                  
  1064                                  inttab_pre:
  1065 00000DB4 00<rep Ch>              	times 3 * inttab_optional.amount db 0
  1066                                  
  1067                                  inttab:
  1068                                  %if _CATCHINT00
  1069 00000DC0 00                      	db 0
  1070 00000DC1 [0000]                  	dw intr0	; table of interrupt initialization stuff
  1071                                  %endif
  1072                                  %if _CATCHINT01
  1073 00000DC3 01                      	db 1
  1074 00000DC4 [0000]                  	dw intr1
  1075                                  %endif
  1076                                  %if _CATCHINT03
  1077 00000DC6 03                      	db 3
  1078 00000DC7 [0000]                  	dw intr3
  1079                                  %endif
  1080                                  %if _CATCHINT07
  1081                                  	db 7
  1082                                  	dw intr7
  1083                                  %endif
  1084                                  %if ! _CATCHINTFAULTCOND && _CATCHINT0C
  1085                                  	db 0Ch
  1086                                  	dw intr0C
  1087                                  %endif
  1088                                  %if ! _CATCHINTFAULTCOND && _CATCHINT0D
  1089                                  	db 0Dh
  1090                                  	dw intr0D
  1091                                  %endif
  1092                                  %if _CATCHINT18
  1093 00000DC9 18                      	db 18h
  1094 00000DCA [0000]                  	dw intr18
  1095                                  %endif
  1096                                  %if _CATCHINT19
  1097 00000DCC 19                      	db 19h
  1098 00000DCD [0000]                  	dw intr19
  1099                                  %endif
  1100                                  %if _CATCHSYSREQ
  1101                                  	db _SYSREQINT
  1102                                  	dw intr_sysreq
  1103                                  %endif
  1104                                  %if _CATCHINT06
  1105 00000DCF 06                      .i06:	db 6
  1106 00000DD0 [0000]                  	dw intr6
  1107                                  %endif
  1108                                  	endarea inttab
  1109                                  	inttab_number equ inttab_size / 3
  1110                                  %if _CATCHINT2D
  1111 00000DD2 2D                      .i2D:	db 2Dh
  1112 00000DD3 [0000]                  	dw int2D
  1113                                  %endif
  1114                                  
  1115                                  
  1116                                  intforcetab:
  1117                                  %if _CATCHINT00
  1118 00000DD5 01                      	db opt4_int_00_force >> 24
  1119                                  %endif
  1120                                  %if _CATCHINT01
  1121 00000DD6 02                      	db opt4_int_01_force >> 24
  1122                                  %endif
  1123                                  %if _CATCHINT03
  1124 00000DD7 04                      	db opt4_int_03_force >> 24
  1125                                  %endif
  1126                                  %if _CATCHINT07
  1127                                  	db opt4_int_07_force >> 24
  1128                                  %endif
  1129                                  %if _CATCHINT0C
  1130 00000DD8 00                      	db opt4_int_0C_force >> 24
  1131                                  %endif
  1132                                  %if _CATCHINT0D
  1133 00000DD9 00                      	db opt4_int_0D_force >> 24
  1134                                  %endif
  1135                                  %if _CATCHINT18
  1136 00000DDA 10                      	db opt4_int_18_force >> 24
  1137                                  %endif
  1138                                  %if _CATCHINT19
  1139 00000DDB 20                      	db opt4_int_19_force >> 24
  1140                                  %endif
  1141                                  %if _CATCHSYSREQ
  1142                                   %if _SYSREQINT == 09h
  1143                                  	db opt4_int_09_force >> 24
  1144                                   %elif _SYSREQINT == 15h
  1145                                  	db opt4_int_15_force >> 24
  1146                                   %else
  1147                                    %error Unknown SysReq interrupt
  1148                                   %endif
  1149                                  %endif
  1150                                  %if _CATCHINT06
  1151 00000DDC 08                      	db opt4_int_06_force >> 24
  1152                                  %endif
  1153                                  
  1154                                  %if _CATCHINT06 && _DETECT95LX
  1155 00000DDD 00                      	align 2, db 0
  1156                                  inttab_number_variable:
  1157 00000DDE 0600                    	dw inttab_number
  1158                                  %endif
  1159                                  
  1160                                  
  1161                                  %if !_LOADER
  1162                                  	align 2, db 0
  1163                                  		; Parameter block for EXEC call
  1164                                  execblk:
  1165 00000DE0 0000                    		dw 0		;(00) zero: copy the parent's environment
  1166 00000DE2 00000000                .cmdline:	dw 0,0		;(02) address of command tail to copy
  1167 00000DE6 5C000000                .fcb1:		dw 5Ch,0	;(06) address of first FCB to copy
  1168 00000DEA 6C000000                .fcb2:		dw 6Ch,0	;(10) address of second FCB to copy
  1169 00000DEE 00000000                .sssp:		dw 0,0		;(14) initial SS:SP
  1170 00000DF2 00000000                .csip:		dw 0,0		;(18) initial CS:IP
  1171                                  %endif
  1172                                  
  1173                                  
  1174                                  		; Register save area (32 words).
  1175                                  		; must be DWORD aligned, used as stack
  1176 00000DF6 00<rep 2h>              	align 4, db 0
  1177                                  regs:
  1178 00000DF8 00000000                reg_eax:	dd 0	;+00 eax
  1179 00000DFC 00000000                reg_ebx:	dd 0	;+04 ebx
  1180 00000E00 00000000                reg_ecx:	dd 0	;+08 ecx
  1181 00000E04 00000000                reg_edx:	dd 0	;+12 edx
  1182 00000E08 00000000                reg_esp:	dd 0	;+16 esp
  1183 00000E0C 00000000                reg_ebp:	dd 0	;+20 ebp
  1184 00000E10 00000000                reg_esi:	dd 0	;+24 esi
  1185 00000E14 00000000                reg_edi:	dd 0	;+28 edi
  1186 00000E18 00000000                reg_ds:		dd 0	;+32  ds (high word unused)
  1187 00000E1C 00000000                reg_es:		dd 0	;+36  es (high word unused)
  1188 00000E20 00000000                reg_ss:		dd 0	;+40  ss (high word unused)
  1189 00000E24 00000000                reg_cs:		dd 0	;+44  cs (high word unused)
  1190 00000E28 00000000                reg_fs:		dd 0	;+48  fs (high word unused)
  1191 00000E2C 00000000                reg_gs:		dd 0	;+52  gs (high word unused)
  1192 00000E30 00000000                reg_eip:	dd 0	;+56 eip
  1193 00000E34 00000000                reg_efl:	dd 0	;+60 efl(ags)
  1194                                  regs.end:
  1195                                  regs.size: equ regs.end - regs
  1196                                  regs.size_w equ regs.size / 2
  1197                                  
  1198                                  %if _REGSHIGHLIGHT
  1199                                  regs_prior:
  1200                                  .:
  1201 00000E38 00000000<rep 10h>       	times 16 dd 0
  1202                                  .end:
  1203                                  .size: equ .end - .
  1204                                  .size_w equ .size / 2
  1205                                  
  1206                                  %if .size != regs.size
  1207                                   %error regs prior save area size mismatch
  1208                                  %endif
  1209                                  %endif
  1210                                  
  1211                                  %if _DEVICE
  1212                                  device_quittable_regs:
  1213                                  .:
  1214 00000E78 00000000<rep 10h>       	times 16 dd 0
  1215                                  .end:
  1216                                  .size: equ .end - .
  1217                                  .size_w equ .size / 2
  1218                                  
  1219                                  %if .size != regs.size
  1220                                   %error regs prior save area size mismatch
  1221                                  %endif
  1222                                  %endif
  1223                                  
  1224                                  %if _VARIABLES
  1225                                  vregs:
  1226                                  .amount: equ 256
  1227 00000EB8 00000000<rep 100h>      	times .amount dd 0	; internal v0..vff
  1228                                   %if _LINK && VREGSAMOUNT != .amount
  1229                                    %error Wrong amount of vregs
  1230                                   %endif
  1231                                  %endif
  1232                                  
  1233                                  %if _BOOTLDR
  1234                                  	align 2, db 0
  1235                                  boot_init_foundname:
  1236 000012B8 00<rep Dh>              	times 8+1+3+1 db 0
  1237                                  %endif
  1238                                  %if _EXECUTABLE
  1239 000012C5 00                      	align 2, db 0
  1240                                  init_executable_pathname:
  1241 000012C6 00<rep 80h>             	times 128 db 0
  1242 00001346 [C612]                  .end:	dw init_executable_pathname
  1243                                  %endif
  1244                                  
  1245                                  ; possible byte encoding of lDebug variables for dynamic computations:
  1246                                  ; xxxxyyyy
  1247                                  ; 10: register
  1248                                  ;   xx: size (0 = 1, 1 = 2, 2 = 4)
  1249                                  ;     yyyy: 0..15: register as stored in the register save area
  1250                                  ;                  as SIL, DIL, BPL, SPL aren't supported these map to xH
  1251                                  ;                  xSL, IPL and FLL are invalid, ExS are invalid
  1252                                  ; 1011: variable
  1253                                  ;     yyyy: which variable. variables are always dword-sized
  1254                                  ; 11000000: 32-bit compound, next byte stores: xxxxyyyy first, second 16-bit reg
  1255                                  ; 11000001..11111111: available for encoding other compound regs, vars, indirection,
  1256                                  ;                     symbols, types etc
  1257                                  ; 0xxxxxxx: operators
  1258                                  
  1259                                  
  1260                                  %if !_LOADER
  1261                                  ; Instruction set information needed for the 'p' command.
  1262                                  ; ppbytes and ppinfo needs to be consecutive.
  1263 00001348 6667262E363E6465F2-     ppbytes:db 66h,67h,26h,2Eh,36h,3Eh,64h,65h,0F2h,0F3h,0F0h	; prefixes
  1263 00001351 F3F0               
  1264                                  PPLEN_ONLY_PREFIXES	equ $-ppbytes
  1265                                  .string:
  1266 00001353 ACADAAABA4A5            	db 0ACh,0ADh,0AAh,0ABh,0A4h,0A5h	; lods,stos,movs
  1267 00001359 6C6D6E6F                	db 6Ch,6Dh,6Eh,6Fh			; ins,outs
  1268 0000135D A6A7AEAF                	db 0A6h,0A7h,0AEh,0AFh			; cmps,scas
  1269                                  PPLEN_ONLY_STRING	equ $-ppbytes
  1270                                  .string_amount:		equ $ - .string
  1271 00001361 CCCD                    	db 0CCh,0CDh				; int instructions
  1272 00001363 E0E1E2                  	db 0E0h,0E1h,0E2h			; loop instructions
  1273 00001366 E8                      	db 0E8h					; call rel16/32
  1274 00001367 9A                      	db 09Ah					; call far seg16:16/32
  1275                                  ;	(This last one is done explicitly by the code.)
  1276                                  ;	db 0FFh					; FF/2 or FF/3: indirect call
  1277                                  
  1278                                  PPLEN	equ	$-ppbytes	; size of the above table
  1279                                  
  1280                                  ;	Info for the above, respectively. This MUST follow
  1281                                  ;	 immediately after ppbytes, as we add + PPLEN - 1 to
  1282                                  ;	 di after repne scasb to index into this (ppinfo).
  1283                                  ;	80h = prefix; 82h = operand size prefix; 81h = address size prefix.
  1284                                  ;	If the high bit is not set, the next highest bit (40h) indicates
  1285                                  ;	 that the instruction size depends on whether there is an operand
  1286                                  ;	 size prefix; if set, under o32 two bytes are added to the size.
  1287                                  ;	 (This is only used for direct near and far call.)
  1288                                  ;	If both the two highest bits are clear, then PP_STRDEST,
  1289                                  ;	 PP_STRSRC, or PP_STRSRC2 may be set. This only happens for
  1290                                  ;	 string instructions, which always are neither prefixes nor
  1291                                  ;	 use additional bytes.
  1292                                  ;	The remaining bits tell the number of additional bytes in the
  1293                                  ;	 instruction. This is at most 4. It must be below-or-equal to
  1294                                  ;	 7, or if PP_VARSIZ is used, 5 (so the sum stays below 8).
  1295                                  
  1296                                  %if 0	; moved to debug.mac
  1297                                  PP_ADRSIZ	equ 01h
  1298                                  PP_OPSIZ	equ 02h
  1299                                  PP_PREFIX	equ 80h
  1300                                  PP_VARSIZ	equ 40h
  1301                                  PP_STRDEST	equ 20h
  1302                                  PP_STRSRC	equ 10h
  1303                                  PP_STRSRC2	equ 08h
  1304                                  PP_SIZ_MASK	equ 07h
  1305                                  %endif
  1306                                  
  1307 00001368 8281                    ppinfo:	db PP_PREFIX | PP_OPSIZ, PP_PREFIX | PP_ADRSIZ
  1308 0000136A 80<rep 9h>              	times 9 db PP_PREFIX		; prefixes
  1309 00001373 1010                    	db PP_STRSRC, PP_STRSRC		; lods
  1310 00001375 2020                    	db PP_STRDEST, PP_STRDEST	; stos
  1311 00001377 3030                    	db PP_STRDEST | PP_STRSRC, PP_STRDEST | PP_STRSRC
  1312                                  					; movs
  1313 00001379 2020                    	db PP_STRDEST, PP_STRDEST	; ins
  1314 0000137B 1010                    	db PP_STRSRC, PP_STRSRC		; outs
  1315 0000137D 1818                    	db PP_STRSRC2 | PP_STRSRC, PP_STRSRC2 | PP_STRSRC
  1316                                  					; cmps
  1317 0000137F 0808                    	db PP_STRSRC2, PP_STRSRC2	; scas
  1318 00001381 0001                    	db 0,1				; int
  1319 00001383 010101                  	db 1,1,1			; loop
  1320 00001386 42                      	db PP_VARSIZ | 2		; call rel16/32 with displacement
  1321 00001387 44                      	db PP_VARSIZ | 4		; call far 16:16 or 16:32 immediate
  1322                                  
  1323                                  %if PPLEN != $-ppinfo
  1324                                   %error "ppinfo table has wrong size"
  1325                                  %endif
  1326                                  
  1327                                  
  1328                                  %include "asmops.mac"
     1                              <1> 
     2                              <1> %if 0
     3                              <1> 
     4                              <1> lDebug assembler/disassembler table operands
     5                              <1> 
     6                              <1> Copyright (C) 1995-2003 Paul Vojta
     7                              <1> Copyright (C) 2008-2026 E. C. Masloch
     8                              <1> 
     9                              <1> Usage of the works is permitted provided that this
    10                              <1> instrument is retained with the works, so that any entity
    11                              <1> that uses the works is notified of this instrument.
    12                              <1> 
    13                              <1> DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
    14                              <1> 
    15                              <1> %endif
    16                              <1> 
    17                              <1> 
    18                              <1> ;	Equates for instruction operands.
    19                              <1> ;	First the sizes.
    20                              <1> 
    21                              <1> OP_ALL		equ 40h		; byte/word/dword operand (could be 30h but ...)
    22                              <1> OP_1632		equ 50h		; word or dword operand
    23                              <1> OP_8		equ 60h		; byte operand
    24                              <1> OP_16		equ 70h		; word operand
    25                              <1> OP_32		equ 80h		; dword operand
    26                              <1> OP_64		equ 90h		; qword operand
    27                              <1> OP_1632_DEFAULT	equ 0A0h	; word or dword or default opsize
    28                              <1> OP_1632_DEFAULT_ASM	equ 0B0h; asm: word or dword or default opsize,
    29                              <1> 				;  disasm: word or dword
    30                              <1> 
    31                              <1> OP_SIZE	equ OP_ALL		; the lowest of these
    32                              <1> 
    33                              <1> ;	These operand types need to be combined with a size.
    34                              <1> ;	Bits 0 to 3 give one of these types (maximum 15),
    35                              <1> ;	 and bits 4 to 7 specify the size. Table entries
    36                              <1> ;	 for these are identified by detecting that they
    37                              <1> ;	 are above-or-equal OP_SIZE.
    38                              <1> ;	The first parameter to the opsizeditem macro is the
    39                              <1> ;	 name of the item. It has to match the names used in
    40                              <1> ;	 the instr.key and debugtbl.inc files.
    41                              <1> ;	The second parameter is the entry for bittab that
    42                              <1> ;	 is used by aa.asm (the assembler).
    43                              <1> ;	The third parameter is the suffix used to create the
    44                              <1> ;	 entry for asmjmp (prefix aop_) and disjmp2 (dop_).
    45                              <1> 
    46                              <1> %macro opsizeditem 3.nolist
    47                              <1>  %1 equ nextindex
    48                              <1>  %xdefine BITTAB_OPSIZEDITEMS BITTAB_OPSIZEDITEMS,%2
    49                              <1>  %xdefine ASMJMP_OPSIZEDITEMS ASMJMP_OPSIZEDITEMS,aop_%3
    50                              <1>  %xdefine DISJMP2_OPSIZEDITEMS DISJMP2_OPSIZEDITEMS,dop_%3
    51                              <1>  %assign nextindex nextindex + 1
    52                              <1> %endmacro
    53                              <1> %assign nextindex 0
    54                              <1> %define BITTAB_OPSIZEDITEMS ""
    55                              <1> %define ASMJMP_OPSIZEDITEMS ""
    56                              <1> %define DISJMP2_OPSIZEDITEMS ""
    57                              <1> opsizeditem OP_IMM,	ARG_IMMED,	imm	; immediate
    58                              <1> opsizeditem OP_IMM_NOT_EXTEND,	ARG_IMMED,	imm_not_extend	; immediate
    59                              <1> 		; This one is for showing the WORD/DWORD size keyword if the
    60                              <1> 		;  value could fit into an imms8.
    61                              <1> opsizeditem OP_RM,ARG_DEREF+ARG_JUSTREG,rm	; reg/mem
    62                              <1> opsizeditem OP_M,	ARG_DEREF,	m	; mem (but not reg)
    63                              <1> opsizeditem OP_R_MOD,	ARG_JUSTREG,	r_mod	; register, determined from MOD R/M part
    64                              <1> opsizeditem OP_MOFFS,	ARG_DEREF,	moffs	; memory offset; e.g., [1234]
    65                              <1> opsizeditem OP_R,	ARG_JUSTREG,	r	; reg part of reg/mem byte
    66                              <1> opsizeditem OP_R_ADD,	ARG_JUSTREG,	r_add	; register, determined from instruction byte
    67                              <1> opsizeditem OP_AX,	ARG_JUSTREG,	ax	; al or ax or eax
    68                              <1> %if nextindex > 16
    69                              <1>  %error Too many op sized items
    70                              <1> %endif
    71                              <1> 
    72                              <1> ;	These don't need a size.
    73                              <1> ;	Because the size needs to be clear to indicate
    74                              <1> ;	 that one of these is to be used, the maximum
    75                              <1> ;	 value for these is 63 (as 64 is OP_SIZE).
    76                              <1> ;	The minimum value for these is 1 because a 0
    77                              <1> ;	 without size means the end of an op list (OP_END).
    78                              <1> ;	The first parameter to the opitem macro is the name
    79                              <1> ;	 of the item. It has to match the names used in the
    80                              <1> ;	 instr.key and debugtbl.inc files.
    81                              <1> ;	The second parameter is the entry for bittab that
    82                              <1> ;	 is used by aa.asm (the assembler). The third
    83                              <1> ;	 parameter is the entry for asmjmp.
    84                              <1> ;	The fourth parameter is the entry for optab as used
    85                              <1> ;	 by uu.asm (the disassembler).
    86                              <1> ;
    87                              <1> ;	asm_siznum contains entries for OP_M64 to OP_MXX.
    88                              <1> ;	 (The order has to match their opitem order.)
    89                              <1> ;	asm_regnum contains entries for OP_DX to OP_GS.
    90                              <1> ;	 (The order has to match their opitem order.)
    91                              <1> 
    92                              <1> %macro opitem 4.nolist
    93                              <1>  %1 equ nextindex
    94                              <1>  %xdefine BITTAB_OPITEMS BITTAB_OPITEMS,%2
    95                              <1>  %xdefine ASMJMP_OPITEMS ASMJMP_OPITEMS,%3
    96                              <1>  %xdefine OPTAB_OPITEMS OPTAB_OPITEMS,%4
    97                              <1>  %assign nextindex nextindex + 1
    98                              <1> %endmacro
    99                              <1> 	OP_END	equ 0
   100                              <1> %assign nextindex 1
   101                              <1> %define BITTAB_OPITEMS ""
   102                              <1> %define ASMJMP_OPITEMS ""
   103                              <1> %define OPTAB_OPITEMS ""
   104                              <1> 	; order of the following (ao17 entries) must match asm_siznum in aa.asm
   105                              <1> OP_FIRST_ASM_SIZNUM	equ nextindex	; corresponding to asm_siznum start
   106                              <1> opitem OP_M64,		ARG_DEREF,	ao17,dop_m64	; qword memory (obsolete?)
   107                              <1> opitem OP_MFLOAT,	ARG_DEREF,	ao17,dop_mfloat	; float memory
   108                              <1> opitem OP_MDOUBLE,	ARG_DEREF,	ao17,dop_mdouble; double-precision floating memory
   109                              <1> opitem OP_M80,		ARG_DEREF,	ao17,dop_m80	; tbyte memory
   110                              <1> opitem OP_MXX,		ARG_DEREF,	ao17,dop_mxx	; memory (size unknown)
   111                              <1> opitem OP_FARIMM,	ARG_FARADDR,	ao21,dop_farimm	; far16/far32 immediate
   112                              <1> opitem OP_FAR_OFFSET,	ARG_IMMED,	aop_faroffset,da_internal_error	; far offset-only
   113                              <1> opitem OP_REL8,		ARG_IMMED,	ao23,dop_rel8	; byte address relative to IP
   114                              <1> opitem OP_REL1632,	ARG_IMMED,	ao25,dop_rel1632; word or dword address relative to IP
   115                              <1> opitem OP_1CHK,		ARG_WEIRDREG,	ao29,dop49	; check for ST(1)
   116                              <1> opitem OP_STI,		ARG_WEIRDREG,	aop_sti,dop_sti	; ST(I)
   117                              <1> opitem OP_CR,		ARG_WEIRDREG,	aop_cr,dop_cr	; CRx
   118                              <1> opitem OP_DR,		ARG_WEIRDREG,	ao34,dop_dr	; DRx
   119                              <1> opitem OP_TR,		ARG_WEIRDREG,	ao35,dop_tr	; TRx
   120                              <1> opitem OP_SEGREG,	ARG_WEIRDREG,	ao39,dop_segreg	; segment register
   121                              <1> opitem OP_IMMS8,	ARG_IMMED,	ao41,dop_imms8 	; sign extended immediate byte
   122                              <1> opitem OP_IMMS8_EXTEND,	ARG_IMMED,	ao41_extend,dop_imms8		; add etc word/dword r/m, imms8
   123                              <1> opitem OP_IMM8,		ARG_IMMED,	ao42,dop_imm8	; immediate byte (other args may be (d)word)
   124                              <1> opitem OP_IMM8_OPTIONAL,ARG_IMMED,	ao42,dop_imm8_optional
   125                              <1> opitem OP_IMM8_INT,	ARG_IMMED,	ao42,dop_imm8_int		; immediate byte for int
   126                              <1> opitem OP_IMM8_SHIFTROT,ARG_IMMED,	ao42,dop_imm8_shiftrot		; immediate byte for shift/rotate
   127                              <1> opitem OP_MMX,		ARG_WEIRDREG,	aop_mmx,dop_mmx	; MMx
   128                              <1> opitem OP_MMX_MOD,	ARG_WEIRDREG,	aop_mmx_mod,dop_mmx_mod	; MMx, but in ModR/M part
   129                              <1> opitem OP_X,		0FFh,	ao_x,	dop_x		; OPX byte follows
   130                              <1> opitem OP_SHOSIZ,	0FFh,	ao44,	dop_shosiz	; set flag to always show the size
   131                              <1> opitem OP_ASM_MOVX,	0FFh,	ao_movx,dop60a		; enforce next operand size to be specified
   132                              <1> opitem OP_SHORT,	0FFh,	ao_short,dop_short	; allow short keyword
   133                              <1> opitem OP_NEAR,		0FFh,	ao_near,dop_near	; allow near keyword
   134                              <1> opitem OP_FAR,		0FFh,	ao_far,	dop_far		; allow far keyword
   135                              <1> opitem OP_FAR_REQUIRED,	0FFh,	ao_far_required,dop_far_required	; require far keyword
   136                              <1> opitem OP_FAR_M,	0FFh,	ao_modifier_continue,dop_far_m		; les, lds, lss, lfs, lgs, or jmp/call far mem
   137                              <1> opitem OP_DOUBLE_M,	0FFh,	ao_modifier_continue,dop_double_m	; bound
   138                              <1> opitem OP_M_SRC,	0FFh,	ao_modifier_continue,dop_m_src
   139                              <1> opitem OP_M_DST,	0FFh,	ao_modifier_continue,dop_m_dst
   140                              <1> opitem OP_M_SRC_DST,	0FFh,	ao_modifier_continue,dop_m_src_dst
   141                              <1> opitem OP_STACK_PUSH,	0FFh,	ac09_internal_error,dop_stack_push
   142                              <1> opitem OP_STACK_POP,	0FFh,	ac09_internal_error,dop_stack_pop
   143                              <1> opitem OP_STACK_SPECIAL,0FFh,	ac09_internal_error,dop_stack_special
   144                              <1> opitem OP_M_ALWAYS_16,	0FFh,	ao_m_always_16,dop_m_always_16
   145                              <1> opitem OP_E_CX,	ARG_JUSTREG,	aop_e_cx, da_e_cx			; (E)CX
   146                              <1> OP_FIRST_STRING equ nextindex
   147                              <1> opitem OP_1,	ARG_IMMED,	ao46, "1"	; 1 (simple "string" ops from here on)
   148                              <1> opitem OP_3,	ARG_IMMED,	ao47, "3"	; 3
   149                              <1> 	; order of the following (ao48 entries) must match asm_regnum in aa.asm
   150                              <1> OP_FIRST_ASM_REGNUM	equ nextindex	; corresponding to asm_regnum start
   151                              <1> opitem OP_DX,	ARG_JUSTREG,	ao48, "DX"	; DX
   152                              <1> opitem OP_CL,	ARG_JUSTREG,	ao48, "CL"	; CL
   153                              <1> opitem OP_ST,	ARG_WEIRDREG,	ao48, "ST"	; ST (top of coprocessor stack)
   154                              <1> opitem OP_CS,	ARG_WEIRDREG,	ao48, "CS"	; CS
   155                              <1> opitem OP_DS,	ARG_WEIRDREG,	ao48, "DS"	; DS
   156                              <1> opitem OP_ES,	ARG_WEIRDREG,	ao48, "ES"	; ES
   157                              <1> opitem OP_FS,	ARG_WEIRDREG,	ao48, "FS"	; FS
   158                              <1> opitem OP_GS,	ARG_WEIRDREG,	ao48, "GS"	; GS
   159                              <1> opitem OP_SS,	ARG_WEIRDREG,	ao48, "SS"	; SS
   160                              <1> OP_AFTER_LAST equ nextindex
   161                              <1> %if nextindex > OP_SIZE
   162                              <1>  %error Too many op items
   163                              <1> %endif
   164                              <1> OP_AMOUNT_TABLE	equ nextindex + 16 - 1
   165                              <1> 		; nextindex: amount sizeless types
   166                              <1> 		; 16: OP_SIZE combined types
   167                              <1> 		; -1: OP_END does not occur in tables
   168                              <1> 
   169                              <1> ; The following are extensions to sizeless OP_ items.
   170                              <1> ;  After an OP_X operand, a byte giving an index into
   171                              <1> ;  the OPX tables follows in the list. This is never
   172                              <1> ;  used with a size so we can make use of the full
   173                              <1> ;  eight bits. First macro parameter is the name which
   174                              <1> ;  matches the use in instr.key. Second parameter is
   175                              <1> ;  the routine in the assembler to dispatch to. Third
   176                              <1> ;  parameter is the routine in the disassembler.
   177                              <1> ; Only used for some disassembler extensions for now.
   178                              <1> 
   179                              <1> %macro opxitem 3.nolist
   180                              <1>  %1 equ nextindex
   181                              <1>  %xdefine ASMJMP_OPXITEMS ASMJMP_OPXITEMS,%2
   182                              <1>  %xdefine DISJMP_OPXITEMS DISJMP_OPXITEMS,%3
   183                              <1>  %assign nextindex nextindex + 1
   184                              <1> %endmacro
   185                              <1> %assign nextindex 0
   186                              <1> %define ASMJMP_OPXITEMS ""
   187                              <1> %define DISJMP_OPXITEMS ""
   188                              <1> opxitem OPX_NOTHING,	ao_modifier_continue, dop60a
   189                              <1> opxitem OPX_MOD_IF_REG,	ao_modifier_continue, dop_mod_if_reg
   190                              <1> opxitem OPX_MOD_IF_MEMOFFS_AND_OTHER_REG_AL_AX_EAX, ao_modifier_continue, 	dop_mod_if_memoffs_and_other_acc
   192                              <1> opxitem OPX_MOD_IF_OTHER_REG_AX_EAX, ao_modifier_continue, 	dop_mod_if_other_acc_1632
   194                              <1> opxitem OPX_MOD_IF_REG_1632, ao_modifier_continue, 	dop_mod_if_reg_1632
   196                              <1> opxitem OPX_MOD_IF_REG_AL_AX_EAX, ao_modifier_continue, 	dop_mod_if_reg_acc
   198                              <1> opxitem OPX_MOD_IF_REG_AX_EAX, ao_modifier_continue, 	dop_mod_if_reg_acc_1632
   200                              <1> opxitem OPX_MODALWAYS_IF_REG, ao_modifier_continue, 	dop_modalways_if_reg
   202                              <1> opxitem OPX_LOOP_OPTION, ac09_internal_error, dop_loop_option
   203                              <1> opxitem OPX_MOD_FORCE_3, ao_modifier_continue, dop_mod_force_3
   204                              <1> %if nextindex > 256
   205                              <1>  %error Too many opx items
   206                              <1> %endif
  1329                                  
  1330                                  
  1331                                  	; Instructions that have an implicit operand subject to a segment prefix.
  1332                                  	; This means a prefixed segment is allowed by the strict assembler, and
  1333                                  	; the disassembler treats a segment prefix as part of the instruction and
  1334                                  	; displays it in front of the instruction's mnemonic.
  1335                                  	; (outs, movs, cmps, lods, xlat).
  1336                                  segprfxtab:
  1337 00001388 6E6FA4A5A6A7ACAD        	db 06Eh,06Fh,0A4h,0A5h,0A6h,0A7h,0ACh,0ADh
  1338                                  a32prfxtab:
  1339 00001390 D7                      	db 0D7h				; xlat, last in segprfxtab, first in a32prfxtab
  1340                                  SEGP_LEN equ $-segprfxtab
  1341                                  
  1342                                  		; Instructions that can be used with REPE/REPNE.
  1343                                  		; (ins, outs, movs, stos, lods; cmps, scas)
  1344 00001391 6C6EA4AAAC              replist:db 06Ch,06Eh,0A4h,0AAh,0ACh	; REP (no difference)
  1345                                  REP_SAME_LEN equ $-replist		; number of indifferent replist entries
  1346 00001396 A6AE                    	db 0A6h,0AEh			; REPE/REPNE
  1347                                  REP_LEN equ $-replist
  1348                                  REP_DIFF_LEN equ REP_LEN-REP_SAME_LEN	; number of replist entries with difference
  1349                                  
  1350                                  A32P_LEN equ $-a32prfxtab
  1351                                  
  1352                                  ; prfxtab P_LEN REP_LEN REPE_REPNE_LEN
  1353                                  
  1354                                  		; All the instructions in replist also have an implicit operand
  1355                                  		; subject to ASIZE (similar to segprfxtab). Additionally, the
  1356                                  		; xlat instruction (0D7h) has such an implicit operand too.
  1357                                  		; maskmovq too.
  1358                                  
  1359                                  	align 2, db 0
  1360                                  o32prfxtab:
  1361 00001398 0E001E0006001600-       	dw 0Eh, 1Eh, 06h, 16h, SPARSE_BASE + 0A0h, SPARSE_BASE + 0A8h
  1361 000013A0 [A000][A800]       
  1362                                  	; push cs, push ds, push es, push ss, push fs, push gs
  1363 000013A4 1F0007001700[A100]-     	dw 1Fh, 07h, 17h, SPARSE_BASE + 0A1h, SPARSE_BASE + 0A9h
  1363 000013AC [A900]             
  1364                                  	; pop ds, pop es, pop ss, pop fs, pop gs
  1365                                  O32P_AMOUNT equ ($ - o32prfxtab) / 2
  1366                                  
  1367                                   %ifn _LINK
  1368                                  	%include "asmtabs.asm"
  1369                                   %endif
  1370                                  %endif
  1371                                  
  1372                                  
  1373                                   %ifn _LINK || _LINK_COMPAT
  1374                                  	usesection lDEBUG_DATA_ENTRY
  1375                                  
  1376                                  msg_start:
  1377                                  	%include "msg.asm"
  1378                                  
  1379                                  msg_end:
  1380                                  
  1381                                  	numdef SHOWMSGSIZE, _DEFAULTSHOWSIZE
  1382                                  %if _SHOWMSGSIZE
  1383                                  %assign MSGSIZE msg_end - msg_start
  1384                                  %warning msg holds MSGSIZE bytes
  1385                                  %endif
  1386                                   %endif
  1387                                  
  1388                                  
  1389                                  	usesection lDEBUG_DATA_ENTRY
  1389          ------------------       note: usesection lDEBUG_DATA_ENTRY
  1390                                  
  1391                                  ..@symhint_trace_caller_entry_to_code_segsel:
  1392                                  entry_to_code_segsel:
  1393                                  %if _PM
  1394                                  	push di
  1395                                  	mov di, word [cs:pm_2_86m_0]
  1396                                  	jmp near word [cs:.table + di]
  1397                                  
  1398                                  		; REM:	Dispatch table in section lDEBUG_DATA_ENTRY
  1399                                  	align 2
  1400                                  .table:
  1401                                  	dw .86m
  1402                                  	dw .pm
  1403                                  
  1404                                  .pm:
  1405                                  	pop di
  1406                                  ..@symhint_trace_caller_entry_to_code_sel:
  1407                                  entry_to_code_sel: equ $
  1408                                  	push ax
  1409                                  	mov ax, word [cs:code_sel]
  1410                                  	jmp entry_to_code_common
  1411                                  
  1412                                  .86m:
  1413                                  	pop di
  1414                                  %endif
  1415                                  
  1416                                  		; INP:	word [cs:ip] = near address to jump to in other segment
  1417                                  ..@symhint_trace_caller_entry_to_code_seg:
  1418                                  entry_to_code_seg:
  1419 000013AE 50                      	push ax			; word space for ?jumpaddress_ip, is ax
  1420 000013AF 2EA1[1C02]              	mov ax, word [cs:code_seg]
  1421                                  
  1422                                  entry_to_code_common:
  1423                                  	lframe 0
  1424                                  	lpar word, jumpaddress_cs_and_orig_ip
  1425                                  	lpar word, jumpaddress_ip
  1426 000013B3 5589E5                  	lenter
  1427                                  
  1428 000013B6 56                      	push si
  1429 000013B7 9C                      	pushf
  1430 000013B8 FC                      	cld
  1431                                  
  1432 000013B9 874604                  	xchg word [bp + ?jumpaddress_cs_and_orig_ip], ax	; fill function segment
  1433 000013BC 89C6                    	mov si, ax
  1434 000013BE 2EAD                    	cs lodsw
  1435                                  %if _DEBUG && !(_LINK || _LINK_COMPAT)
  1436                                  	cmp al, 0CCh		; debugger breakpoint ?
  1437                                  	jne @F			; no -->
  1438                                  	int3			; break to make it remove the breakpoint
  1439                                  	dec si
  1440                                  	dec si
  1441                                  	cs lodsw		; reload the word
  1442                                  	cmp al, 0CCh
  1443                                  	jne @F
  1444                                  
  1445                                  .l:
  1446                                  	int3
  1447                                  	jmp .l
  1448                                  
  1449                                  @@:
  1450                                  %endif
  1451 000013C0 874602                  	xchg word [bp + ?jumpaddress_ip], ax		; fill function offset
  1452                                  		; (and restore ax)
  1453                                  
  1454 000013C3 9D                      	popf
  1455 000013C4 5E                      	pop si
  1456                                  
  1457 000013C5 5D                      	lleave
  1458 000013C6 CB                      	retf			; jump to dword [bp + ?jumpaddress]
  1459                                  
  1460                                  
  1461                                  %if !_LOADER
  1462                                  		; debug22 - Interrupt 22h handler
  1463                                  		;
  1464                                  		; This is for DEBUG itself: it's a catch-all for the various Int23
  1465                                  		; and Int24 calls that may occur unpredictably at any time. What we
  1466                                  		; do is pretend to be a command interpreter (which we are, in a sense,
  1467                                  		; just with different sort of commands) by setting our parent PSP
  1468                                  		; value equal to our own PSP so that DOS does not free our memory when
  1469                                  		; we quit. Therefore control ends up here when DOS detects Control-C
  1470                                  		; or an Abort in the critical error prompt is selected.
  1471                                  debug22:
  1472 000013C7 FA                      	cli
  1473                                  .cleartraceflag:
  1474 000013C8 FC                      	cld			; reestablish things
  1475 000013C9 8CC8                    	mov ax, cs
  1476 000013CB 8ED8                    	mov ds, ax
  1477 000013CD 8ED0                    	mov ss, ax
  1478 000013CF 8B26[380C]              	mov sp, word [ savesp ]	; restore stack
  1479                                  %if _PM
  1480                                  	mov byte [pm_2_86m_0], 0
  1481                                  	clropt [internalflags], protectedmode	; reset PM flag
  1482                                  %endif
  1483                                  	times 1 - (($ - $$) & 1) nop	; align in-code parameter
  1484 000013D3 E8D8FF                  	call entry_to_code_seg
  1485 000013D6 [0D05]                  	dw cmd2_reset_re_maybe_pm
  1486                                  %endif
  1487                                  
  1488                                  
  1489                                  %if _DUALCODE
  1490                                  	usesection lDEBUG_CODE2
  1491                                   %if $ - $$
  1492                                    %error cmd3_mirror is not at offset 0 in lDEBUG_CODE2
  1493                                   %endif
  1494                                  cmd3_mirror:
  1495                                  	db 0B9h				; mov cx, imm16 (cx = nonzero)
  1496                                  	xor cx, cx			; cx = 0
  1497                                  	dualcall cmd3.have_cx_convenience
  1498                                  %endif
  1499                                  
  1500                                  
  1501                                  	usesection lDEBUG_CODE
  1501          ------------------       note: usesection lDEBUG_CODE
  1502                                  %if $ - $$
  1503                                   %error cmd3 is not at offset 0 in lDEBUG_CODE
  1504                                  %endif
  1505                                  
  1506                                  	code_insure_low_byte_not_0CCh
  1507                                  		; Begin main command loop.
  1508                                  cmd3: section_of_function
  1509                                  		; A convenience entrypoint: Entering
  1510                                  		;  cmd3 at offset 1 instead of 0 will
  1511                                  		;  make the debugger additionally
  1512                                  		;  display a linebreak early on.
  1513 00000000 B9                      	db 0B9h				; mov cx, imm16 (cx = nonzero)
  1514 00000001 31C9                    	xor cx, cx			; cx = 0
  1515                                  .have_cx_convenience:
  1516                                  
  1517 00000003 16                      	push ss
  1518 00000004 1F                      	pop ds
  1519 00000005 66                      	_386_o32		; mov esp
  1520 00000006 8B26[380C]              	mov sp, word [ savesp ]		; restore stack
  1521 0000000A 83E4FC                  _386	and sp, ~3			; align stack
  1522 0000000D 66                      	_386_o32
  1523 0000000E 31C0                    	xor ax, ax
  1524 00000010 66                      	_386_o32
  1525 00000011 50                      	push ax
  1526 00000012 66                      	_386_o32
  1527 00000013 9D                      	popf
  1528 00000014 8B26[380C]              _386	mov sp, word [ savesp ]		; restore stack
  1529 00000018 FC                      	cld
  1530 00000019 FB                      	sti
  1531 0000001A C706[3E0C][0000]        	mov word [ errret ], cmd3
  1532 00000020 C706[400C][0012]        	mov word [ throwret ], errhandler
  1533 00000026 8926[420C]              	mov word [ throwsp ], sp
  1534                                  %if _SYMBOLIC
  1535                                  	mov word [ stack_low_address ], str_buffer
  1536                                  %endif
  1537 0000002A 31C0                    	xor ax, ax
  1538                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  1539 0000002C A3[5202]                	mov word [in_getinput], ax	; set this byte and reserved next byte
  1540                                  %endif
  1541 0000002F 8706[880B]              	xchg ax, word [cmd3_set_options]
  1542 00000033 0906[A001]              	or word [options], ax
  1543                                  
  1544 00000037 1E                      	push ds
  1545 00000038 07                      	pop es
  1546 00000039 E302                    	jcxz @F
  1547 0000003B EB06                    	jmp @FF
  1548                                  @@:
  1549 0000003D BA[0000]                	mov dx, crlf
  1550 00000040 E8(0000)                	call putsz
  1551                                  @@:
  1552                                  
  1553                                  %if _SYMBOLIC
  1554                                  	clropt [internalflags2], dif2_xms_detection_done
  1555                                  	nearcall zz_save_strat
  1556                                  %endif
  1557                                  
  1558 00000043 31FF                    	xor di, di
  1559 00000045 873E[8E0D]              	xchg di, word [terminator_in_line_in.offset]
  1560 00000049 85FF                    	test di, di
  1561 0000004B 7409                    	jz @F
  1562 0000004D 803D00                  	cmp byte [di], 0
  1563 00000050 7504                    	jne @F
  1564 00000052 A0[900D]                	mov al, byte [terminator_in_line_in.value]
  1565 00000055 AA                      	stosb
  1566                                  @@:
  1567                                  
  1568 00000056 8326[480C]00            	and word [run_sp_reserve], 0
  1569                                  %if !_LOADER
  1570                                  %if _RH || _SWHILEBUFFER || _RECMDWHILEBUFFER || _EXTENSIONS
  1571 0000005B D006[1402]              	rol byte [in_re], 1
  1572 0000005F 7205                    	jc @F
  1573 00000061 8026[DB01]FB            	clropt [internalflags], tt_while
  1574                                  @@:
  1575                                  %endif
  1576                                  %endif
  1577                                  %if _RH
  1578 00000066 8026[EE01]EF            	clropt [internalflags6], dif6_rh_mode
  1579 0000006B C606[1302]00            	mov byte [skip_rh], 0
  1580                                  %endif
  1581                                  %if _IMMASM
  1582 00000070 8026[EF01]FC            	clropt [internalflags6], dif6_immasm_no_output | dif6_immasm
  1583                                  %endif
  1584 00000075 8026[E101]DF            	clropt [internalflags3], dif3_unquiet_error
  1585                                  %if _REGSHIGHLIGHT
  1586 0000007A 8026[E201]FD            	clropt [internalflags3], dif3_do_not_highlight
  1587                                  %endif
  1588                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  1589 0000007F 8026[E301]E7            	clropt [internalflags3], dif3_auxbuff_guarded_1 | dif3_in_if
  1590                                  %else
  1591                                  	clropt [internalflags3], dif3_auxbuff_guarded_1
  1592                                  %endif
  1593 00000084 8026[E001]CF            	clropt [internalflags3], 		dif3_input_serial_override | dif3_input_terminal_override
  1595 00000089 8026[DF01]EF            	clropt [internalflags2], dif2_in_silence_dump
  1596                                  %if _PM
  1597                                   %if _DEBUG
  1598                                  	clropt [internalflags6], dif6_in_hook2F | dif6_in_amis_hook2F
  1599                                   %else
  1600                                  	clropt [internalflags6], dif6_in_amis_hook2F
  1601                                   %endif
  1602                                  	call resetmode
  1603                                  %endif
  1604                                  
  1605                                  %ifn _VXCHG
  1606                                  	mov ah, 0Fh
  1607                                  	int 10h
  1608                                  	mov byte [vpage], bh			; update page
  1609                                  %endif
  1610                                  
  1611                                  %if _TEST_HELP_FILE
  1612                                  cmd3_close_handle:
  1613                                  	call InDOS
  1614                                  	jnz @F
  1615                                  	mov ah, 3Eh
  1616                                  	mov bx, -1
  1617                                  	xchg bx, [handle]
  1618                                  	cmp bx, -1
  1619                                  	je @F
  1620                                  	doscall
  1621                                  @@:
  1622                                  %endif
  1623                                  
  1624                                  %if _EXTENSIONS
  1625                                  cmd3_close_ext:
  1626 0000008E E8(0000)                	call close_ext
  1627                                  %endif
  1628                                  
  1629                                  %if _RH
  1630                                  cmd3_rh_init:
  1631 00000091 F606[B601]10            	testopt [options6], opt6_rh_mode
  1632 00000096 7419                    	jz .check_disable
  1633                                  .check_enable:
  1634 00000098 F606[EE01]08            	testopt [internalflags6], dif6_rh_mode_was
  1635 0000009D 7529                    	jnz .done
  1636                                  .enable:
  1637                                  		; guarded_1 is always reset by cmd3
  1638                                  		; guarded_2 is only set by RE indicating silent mode
  1639                                  		; so we never want to not enable RH mode
  1640 0000009F 800E[E301]40            	setopt [internalflags3], dif3_auxbuff_guarded_3
  1641 000000A4 800E[EE01]08            	setopt [internalflags6], dif6_rh_mode_was
  1642                                  
  1643 000000A9 E8(0000)                	call tpg_initialise_empty_auxbuff.reset
  1644                                  
  1645 000000AC BA[0000]                	mov dx, msg.rh_enabled
  1646 000000AF EB14                    	jmp .done_putsz
  1647                                  
  1648                                  .check_disable:
  1649 000000B1 F606[EE01]08            	testopt [internalflags6], dif6_rh_mode_was
  1650 000000B6 7410                    	jz .done
  1651                                  .disable:
  1652 000000B8 8026[E301]BF            	clropt [internalflags3], dif3_auxbuff_guarded_3
  1653 000000BD 8026[EE01]F7            	clropt [internalflags6], dif6_rh_mode_was
  1654 000000C2 BA[0000]                	mov dx, msg.rh_disabled
  1655                                  
  1656                                  .done_putsz:
  1657 000000C5 E8(0000)                	call putsz
  1658                                  .done:
  1659                                  %endif
  1660                                  
  1661                                  %if _DEBUG && _DEBUG_COND
  1662                                  cmd3_debug_mode_init:
  1663 000000C8 F606[B501]01            	testopt [options6], opt6_debug_mode
  1664 000000CD 7411                    	jz .check_disable
  1665                                  .check_enable:
  1666 000000CF F606[ED01]01            	testopt [internalflags6], dif6_debug_mode
  1667 000000D4 7519                    	jnz .done
  1668 000000D6 E8(0000)                	call reset_interrupts
  1669 000000D9 800E[ED01]01            	setopt [internalflags6], dif6_debug_mode
  1670 000000DE EB0F                    	jmp .done
  1671                                  
  1672                                  .check_disable:
  1673 000000E0 F606[ED01]01            	testopt [internalflags6], dif6_debug_mode
  1674 000000E5 7408                    	jz .done
  1675 000000E7 E8(0000)                	call set_interrupts
  1676 000000EA 8026[ED01]FE            	clropt [internalflags6], dif6_debug_mode
  1677                                  .done:
  1678                                   %endif
  1679                                  
  1680                                  
  1681                                  %if _PM
  1682                                  cmd3_int2F_init:
  1683                                  	mov al, 2Fh		; interrupt number
  1684                                  	mov si, debug2F		; -> IISP entry header
  1685                                  
  1686                                  	testopt [options4], opt4_int_2F_hook
  1687                                  	jnz .done
  1688                                  .check_disable:
  1689                                  	mov dx, opt4_int_2F_force >> 16
  1690                                   %if (opt4_int_2F_force >> 16) == dif4_int_2F_hooked
  1691                                  	call cmd3_int_disable.set_bx_to_dx
  1692                                   %else
  1693                                  	mov bx, dif4_int_2F_hooked
  1694                                  	call cmd3_int_disable
  1695                                   %endif
  1696                                  	jc .done
  1697                                  	clropt [internalflags], hooked2F
  1698                                  
  1699                                  .done:
  1700                                  %endif
  1701                                  
  1702                                  
  1703                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  1704                                  cmd3_int0D_init:
  1705 000000EF B00D                    	mov al, 0Dh		; interrupt number
  1706 000000F1 BE[0000]                	mov si, intr0D		; -> IISP entry header
  1707 000000F4 BA1000                  	mov dx, opt4_int_0D_force >> 16
  1708                                   %if (opt4_int_0D_force >> 16) == dif4_int_0D_hooked
  1709 000000F7 89D3                    	mov bx, dx
  1710                                   %else
  1711                                  	mov bx, dif4_int_0D_hooked
  1712                                   %endif
  1713                                  
  1714 000000F9 F606[AC01]10            	testopt [options4], opt4_int_fault_hook
  1715 000000FE 7405                    	jz .check_disable
  1716                                  .check_enable:
  1717 00000100 E8CF05                  	call cmd3_int_enable
  1718 00000103 EB03                    	jmp .done
  1719                                  
  1720                                  .check_disable:
  1721 00000105 E8DF05                  	call cmd3_int_disable
  1722                                  
  1723                                  .done:
  1724                                  %endif
  1725                                  
  1726                                  
  1727                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  1728                                  cmd3_int0C_init:
  1729 00000108 B00C                    	mov al, 0Ch		; interrupt number
  1730 0000010A BE[0000]                	mov si, intr0C		; -> IISP entry header
  1731 0000010D BA2000                  	mov dx, opt4_int_0C_force >> 16
  1732                                   %if (opt4_int_0C_force >> 16) == dif4_int_0C_hooked
  1733 00000110 89D3                    	mov bx, dx
  1734                                   %else
  1735                                  	mov bx, dif4_int_0C_hooked
  1736                                   %endif
  1737                                  
  1738 00000112 F606[AC01]10            	testopt [options4], opt4_int_fault_hook
  1739 00000117 7405                    	jz .check_disable
  1740                                  .check_enable:
  1741 00000119 E8B605                  	call cmd3_int_enable
  1742 0000011C EB03                    	jmp .done
  1743                                  
  1744                                  .check_disable:
  1745 0000011E E8C605                  	call cmd3_int_disable
  1746                                  
  1747                                  .done:
  1748                                  %endif
  1749                                  
  1750                                  
  1751                                  %if _CATCHINT08
  1752                                  cmd3_int08_init:
  1753 00000121 B008                    	mov al, 08h		; interrupt number
  1754 00000123 BE[0000]                	mov si, intr8		; -> IISP entry header
  1755 00000126 BA0400                  	mov dx, opt4_int_08_force >> 16
  1756                                   %if (opt4_int_08_force >> 16) == dif4_int_08_hooked
  1757 00000129 89D3                    	mov bx, dx
  1758                                   %else
  1759                                  	mov bx, dif4_int_08_hooked
  1760                                   %endif
  1761                                  
  1762 0000012B F606[AC01]04            	testopt [options4], opt4_int_08_hook
  1763 00000130 7405                    	jz .check_disable
  1764                                  .check_enable:
  1765 00000132 E89D05                  	call cmd3_int_enable
  1766 00000135 EB03                    	jmp .done
  1767                                  
  1768                                  .check_disable:
  1769 00000137 E8AD05                  	call cmd3_int_disable
  1770                                  
  1771                                  .done:
  1772                                  %endif
  1773                                  
  1774                                  
  1775                                  %if _CATCHINT2D
  1776                                  cmd3_int2D_init:
  1777 0000013A B02D                    	mov al, 2Dh		; interrupt number
  1778 0000013C BE[0000]                	mov si, int2D		; -> IISP entry header
  1779 0000013F BB0800                  	mov bx, dif4_int_2D_hooked
  1780 00000142 BA0800                  	mov dx, opt4_int_2D_force >> 16
  1781                                  
  1782 00000145 F606[AC01]08            	testopt [options4], opt4_int_2D_hook
  1783 0000014A 7445                    	jz .check_disable
  1784                                  .check_enable:
  1785 0000014C 851E[E401]              	test word [internalflags4], bx
  1786 00000150 7542                    	jnz .done
  1787                                  
  1788 00000152 E8(0000)                	call intchk			; ZR if offset = -1 or segment = 0
  1789                                  					; CHG: ax, dx, bx
  1790 00000155 742D                    	jz .fail
  1791                                  
  1792 00000157 8A26[0000]              	mov ah, byte [try_amis_multiplex_number]
  1793 0000015B B000                    	mov al, 00h
  1794                                  		; function 0 changes dx, di, cx, al
  1795                                  %if _PM
  1796                                  	call call_int2D
  1797                                  %else
  1798 0000015D CD2D                    	int 2Dh				; enquire whether there's anyone
  1799                                  %endif
  1800 0000015F 84C0                    	test al, al
  1801 00000161 7413                    	jz .got
  1802                                  
  1803 00000163 31C0                    	xor ax, ax			; start with multiplex number 0
  1804                                  .loopplex:
  1805 00000165 B000                    	mov al, 00h			; AMIS installation check
  1806                                  		; function 0 changes dx, di, cx, al
  1807                                  %if _PM
  1808                                  	call call_int2D
  1809                                  %else
  1810 00000167 CD2D                    	int 2Dh				; enquire whether there's anyone
  1811                                  %endif
  1812 00000169 84C0                    	test al, al			; free ?
  1813 0000016B 7409                    	jz .got				; yes, put it to use -->
  1814 0000016D FEC4                    	inc ah
  1815 0000016F 75F4                    	jnz .loopplex			; try next multiplexer -->
  1816                                  
  1817 00000171 BA[0000]                	mov dx, msg.cannot_hook_2D.nofree
  1818 00000174 EB11                    	jmp .fail_putsz
  1819                                  
  1820                                  .got:
  1821 00000176 8826[0000]              	mov byte [amis_multiplex_number], ah
  1822                                  
  1823 0000017A B02D                    	mov al, 2Dh		; interrupt number
  1824 0000017C BB0800                  	mov bx, dif4_int_2D_hooked
  1825 0000017F E85605                  	call cmd3_int_enable.need
  1826 00000182 EB10                    	jmp .done
  1827                                  
  1828                                  .fail:
  1829 00000184 BA[0000]                	mov dx, msg.cannot_hook_2D.invalid
  1830                                  .fail_putsz:
  1831 00000187 E8(0000)                	call putsz
  1832 0000018A 8026[AC01]F7            	clropt [options4], opt4_int_2D_hook
  1833 0000018F EB03                    	jmp .done
  1834                                  
  1835                                  .check_disable:
  1836 00000191 E85305                  	call cmd3_int_disable
  1837                                  
  1838                                  .done:
  1839                                  %endif
  1840                                  
  1841                                  
  1842 00000194 F606[E301]01            	testopt [internalflags3], dif3_input_re
  1843 00000199 7403E9C101              	jnz cmd3_continue_1_re
  1844 0000019E 8026[A501]7F            	clropt [options2], opt2_re_cancel_tpg
  1845                                  %if !_LOADER
  1846 000001A3 E8(0000)                	call silence_dump
  1847                                  %endif
  1848                                  
  1849                                  
  1850                                  cmd3_serial_init:
  1851 000001A6 F606[A101]40            	testopt [options], enable_serial
  1852 000001AB 7503E95701              	jz .check_disable_serial
  1853                                  .check_enable_serial:
  1854 000001B0 F606[690D]01            	testopt [serial_flags], sf_init_done
  1855 000001B5 7408                    	jz .enable_serial
  1856                                  		; If we disabled the actual use flag prior somehow
  1857                                  		;  (sf_use_serial clear) but we get here with
  1858                                  		;  sf_init_done set then re-enable use of serial I/O.
  1859 000001B7 800E[690D]10            	setopt [serial_flags], sf_use_serial
  1860 000001BC E98F01                  	jmp .done_serial
  1861                                  
  1862                                  .enable_serial:
  1863                                  
  1864 000001BF A0[6A0D]                	mov al, byte [serial_var_intnum]
  1865 000001C2 A2[E80B]                	mov byte [serial_use_intnum], al
  1866 000001C5 A0[6B0D]                	mov al, byte [serial_var_params]
  1867 000001C8 A2[E90B]                	mov byte [serial_use_params], al
  1868 000001CB A0[6C0D]                	mov al, byte [serial_var_fifo]
  1869 000001CE A2[EA0B]                	mov byte [serial_use_fifo], al
  1870 000001D1 A1[6E0D]                	mov ax, word [serial_var_baseport]
  1871 000001D4 A3[EE0B]                	mov word [serial_use_baseport], ax
  1872 000001D7 A1[700D]                	mov ax, word [serial_var_dl]
  1873 000001DA A3[F00B]                	mov word [serial_use_dl], ax
  1874 000001DD A1[720D]                	mov ax, word [serial_var_irqmask]
  1875 000001E0 A3[F20B]                	mov word [serial_use_irqmask], ax
  1876 000001E3 E8(0000)                  call  serial_clear_fifos
  1877 000001E6 E8(0000)                  call  serial_install_interrupt_handler
  1878 000001E9 7317                    	jnc @F
  1879 000001EB BF[0000]                	mov di, msg.serial_cannot_hook.old_int
  1880 000001EE A0[980D]                	mov al, byte [serial_installed_intnum]
  1881 000001F1 E8(0000)                	call hexbyte
  1882 000001F4 BF[0000]                	mov di, msg.serial_cannot_hook.new_int
  1883 000001F7 A0[E80B]                	mov al, byte [serial_use_intnum]
  1884 000001FA E8(0000)                	call hexbyte
  1885 000001FD BA[0000]                	mov dx, msg.serial_cannot_hook
  1886 00000200 EB5C                    	jmp .no_keep
  1887                                  
  1888                                  @@:
  1889 00000202 C606[0800]80            	mov byte [serial_interrupt_handler + ieEOI], 80h
  1890 00000207 E8(0000)                  call  serial_init_UART
  1891                                  
  1892 0000020A 800E[690D]11            	setopt [serial_flags], sf_init_done | sf_use_serial
  1893                                  
  1894 0000020F BA[0000]                	mov dx, msg.serial_request_keep
  1895 00000212 E8(0000)                	call putsz
  1896                                  
  1897 00000215 BF[CE0A]                	mov di, line_out
  1898                                  %if _DEBUG
  1899                                   %if _DEBUG_COND
  1900 00000218 F606[ED01]01            	testopt [internalflags6], dif6_debug_mode
  1901 0000021D 7403                    	jz @F
  1902                                   %endif
  1903 0000021F B07E                    	mov al, '~'		; indicate instance is to be debugged
  1904 00000221 AA                      	stosb
  1905                                  @@:
  1906                                  %endif
  1907 00000222 B83D20                  	mov ax, "= "
  1908 00000225 AB                      	stosw
  1909                                  
  1910 00000226 31C0                    	xor ax, ax
  1911 00000228 A3[800D]                	mov word [getline_timer_count], ax
  1912 0000022B 06                      	push es
  1913 0000022C B84000                  	mov ax, 40h
  1914 0000022F 8EC0                    	mov es, ax
  1915 00000231 26A16C00                	mov ax, word [es:6Ch]
  1916 00000235 A3[820D]                	mov word [getline_timer_last], ax
  1917 00000238 07                      	pop es
  1918 00000239 C706[840D][6E02]        	mov word [getline_timer_func], .timer
  1919                                  
  1920                                  		; if we're executing from the command line
  1921                                  		;  buffer or a Y file then we want to
  1922                                  		;  override input to be from serial for the
  1923                                  		;  KEEP confirmation prompt.
  1924                                  		; output is always to serial if we're here.
  1925 0000023F 800E[E001]20            	setopt [internalflags3], dif3_input_serial_override
  1926 00000244 E8(0000)                	call getline00
  1927 00000247 8026[E001]DF            	clropt [internalflags3], dif3_input_serial_override
  1928                                  
  1929 0000024C E8(0000)                	call skipcomm0
  1930 0000024F 4E                      	dec si
  1931 00000250 BA[0000]                	mov dx, msg.keep
  1932 00000253 E8(0000)                	call isstring?
  1933 00000256 7503E9F300              	je .done_serial
  1934                                  
  1935 0000025B BA[0000]                	mov dx, msg.serial_no_keep_enter
  1936                                  .no_keep:
  1937                                  		; Immediately disable use of serial I/O.
  1938 0000025E 8026[690D]EF            	clropt [serial_flags], sf_use_serial
  1939                                  		; Set the flag for next cmd3 loop to properly disable
  1940                                  		;  and de-initialise the serial port.
  1941 00000263 8026[A101]BF            	clropt [options], enable_serial
  1942 00000268 E8(0000)                	call putsz
  1943 0000026B E992FD                  	jmp cmd3
  1944                                  
  1945                                  
  1946                                  .timer:
  1947 0000026E 50                      	push ax
  1948 0000026F 52                      	push dx
  1949 00000270 51                      	push cx
  1950 00000271 53                      	push bx
  1951 00000272 06                      	push es
  1952                                  
  1953 00000273 BA4000                  	mov dx, 40h
  1954 00000276 8EC2                    	mov es, dx
  1955                                  
  1956 00000278 B00B                      mov al, 0Bh	; request In-Service Register (ISR)
  1957 0000027A E6A0                      out 0A0h, al	; from secondary PIC
  1958 0000027C E4A0                      in al, 0A0h	; read the ISR
  1959 0000027E 8406[F30B]                test al, byte [serial_use_irqmask + 1]
  1960 00000282 756B                      jnz .timer_ours
  1961 00000284 B00B                      mov al, 0Bh	; request In-Service Register (ISR)
  1962 00000286 E620                      out 20h, al	; from primary PIC
  1963 00000288 E420                      in al, 20h	; read the ISR
  1964 0000028A 24FB                      and al, ~100b
  1965 0000028C 8406[F20B]                test al, byte [serial_use_irqmask]
  1966 00000290 755D                      jnz .timer_ours
  1967                                  .timer_ours_done:
  1968                                  
  1969 00000292 8B0E[DE0B]                mov cx, word [serial_save_irq_mask]
  1970 00000296 31DB                      xor bx, bx		; all bits clear (= IRQ ON)
  1971 00000298 E8(0000)                  call set_irq		; enable IRQs and get prior status
  1972 0000029B 85DB                      test bx, bx		; IRQs were still enabled ?
  1973 0000029D 7405                      jz @F			; yes, fine -->
  1974 0000029F 8026[B601]FE              clropt [options6], opt6_share_serial_irq
  1975                                  			; no, make sure not to chain any longer
  1976                                  @@:
  1977 000002A4 8B0E[800D]              	mov cx, word [getline_timer_count]
  1978 000002A8 8B16[820D]              	mov dx, word [getline_timer_last]
  1979                                  
  1980                                  %if _SLEEP_NEW
  1981 000002AC 26A16C00                	mov ax, word [es:6Ch]
  1982 000002B0 39C2                    	cmp dx, ax
  1983 000002B2 7445                    	je .timer_next
  1984 000002B4 F7DA                    	neg dx			; minus prior tick
  1985 000002B6 01C2                    	add dx, ax		; new tick - prior tick
  1986                                  
  1987 000002B8 3B16[0000]              	cmp dx, word [sleep_delta_limit]
  1988 000002BC 7609                    	jbe @F
  1989 000002BE 8B16[0000]              	mov dx, word [sleep_delta_limit]
  1990 000002C2 85D2                    	test dx, dx
  1991 000002C4 7501                    	jnz @F
  1992 000002C6 42                      	inc dx			; limit 0 would lead to stagnant sleep
  1993                                  @@:
  1994 000002C7 3B16[0000]              	cmp dx, word [sleep_highest_delta]
  1995 000002CB 7604                    	jbe @F
  1996 000002CD 8916[0000]              	mov word [sleep_highest_delta], dx
  1997                                  @@:
  1998 000002D1 01D1                    	add cx, dx
  1999 000002D3 7303                    	jnc @F
  2000 000002D5 B9FFFF                  	mov cx, -1
  2001                                  @@:
  2002 000002D8 89C2                    	mov dx, ax
  2003                                  %else
  2004                                  	cmp dx, word [es:6Ch]
  2005                                  	je .timer_next
  2006                                  	mov dx, word [es:6Ch]
  2007                                  	inc cx
  2008                                  %endif
  2009 000002DA B012                    	mov al, 18
  2010 000002DC F626[670D]              	mul byte [serial_keep_timeout]
  2011 000002E0 85C0                    	test ax, ax
  2012 000002E2 7415                    	jz .timer_next
  2013 000002E4 39C1                    	cmp cx, ax
  2014 000002E6 7211                    	jb .timer_next
  2015                                  
  2016 000002E8 07                      	pop es
  2017 000002E9 BA[0000]                	mov dx, msg.serial_no_keep_timer
  2018 000002EC E96FFF                  	jmp .no_keep
  2019                                  
  2020                                  .timer_ours:
  2021 000002EF 800E[B601]02            	setopt [options6], opt6_serial_EOI_call
  2022 000002F4 E8(0000)                  call serial_eoi
  2023 000002F7 EB99                    	jmp .timer_ours_done
  2024                                  
  2025                                  .timer_next:
  2026 000002F9 890E[800D]              	mov word [getline_timer_count], cx
  2027 000002FD 8916[820D]              	mov word [getline_timer_last], dx
  2028 00000301 07                      	pop es
  2029 00000302 5B                      	pop bx
  2030 00000303 59                      	pop cx
  2031 00000304 5A                      	pop dx
  2032 00000305 58                      	pop ax
  2033 00000306 C3                      	retn
  2034                                  
  2035                                  
  2036                                  .check_disable_serial:
  2037                                  		; If serial is initialised, uninstall it.
  2038 00000307 F606[690D]01            	testopt [serial_flags], sf_init_done
  2039 0000030C 751D                    	jnz .disable_serial
  2040                                  		; Not initialised. Is the interrupt still hooked?
  2041 0000030E F606[E401]01            	testopt [internalflags4], dif4_int_serial_hooked
  2042 00000313 7439                    	jz .done_serial
  2043                                  		; Try unhooking the interrupt handler.
  2044 00000315 E8(0000)                	call serial_uninstall_interrupt_handler
  2045 00000318 7234                    	jc .done_serial			; if it failed again -->
  2046 0000031A BF[0000]                	mov di, msg.serial_late_unhook.int
  2047 0000031D A0[980D]                	mov al, byte [serial_installed_intnum]
  2048 00000320 E8(0000)                	call hexbyte
  2049 00000323 BA[0000]                	mov dx, msg.serial_late_unhook
  2050 00000326 E8(0000)                	call putsz
  2051 00000329 EB23                    	jmp .done_serial
  2052                                  
  2053                                  .disable_serial:
  2054                                  
  2055 0000032B E8(0000)                  call serial_clean_up
  2056 0000032E 7319                    	jnc @F
  2057                                  		; Immediately disable use of serial I/O,
  2058                                  		;  so that our error message goes to the
  2059                                  		;  local terminal rather than to serial I/O.
  2060 00000330 8026[690D]EF            	clropt [serial_flags], sf_use_serial
  2061 00000335 BF[0000]                	mov di, msg.serial_cannot_unhook.int
  2062 00000338 A0[980D]                	mov al, byte [serial_installed_intnum]
  2063 0000033B E8(0000)                	call hexbyte
  2064 0000033E BA[0000]                	mov dx, msg.serial_cannot_unhook
  2065 00000341 E8(0000)                	call putsz
  2066 00000344 C606[0800]00            	mov byte [serial_interrupt_handler + ieEOI], 0
  2067                                  					; we do not issue EOI any longer
  2068                                  @@:
  2069 00000349 8026[690D]EE            	clropt [serial_flags], sf_init_done | sf_use_serial
  2070                                  .done_serial:
  2071                                  
  2072                                  
  2073                                  %if _VXCHG
  2074                                  cmd3_vv_set:
  2075 0000034E E8(0000)                	call vv_set
  2076                                  %endif
  2077                                  
  2078                                  
  2079                                  %if _PM
  2080                                  cmd3_ss_init:
  2081                                  	call ispm
  2082                                  	jnz .done
  2083                                  
  2084                                  subcpu 286
  2085                                  	mov bx, ss
  2086                                  	lar cx, bx
  2087                                  	jnz .done
  2088                                  	shr cx, 8
  2089                                  
  2090                                  	testopt [options3], opt3_ss_b_bit_set
  2091                                  	jz .check_clear
  2092                                  .check_set:
  2093                                  	testopt [internalflags3], dif3_ss_b_bit_set
  2094                                  	jnz .done
  2095                                  
  2096                                  	mov ch, 40h
  2097                                  	jmp @F
  2098                                  
  2099                                  .check_clear:
  2100                                  	testopt [internalflags3], dif3_ss_b_bit_set
  2101                                  	jz .done
  2102                                  
  2103                                  @@:
  2104                                  	mov ax, 0009h
  2105                                  	int 31h
  2106                                  	jc .done
  2107                                  
  2108                                  	xoropt [internalflags3], dif3_ss_b_bit_set
  2109                                  subcpureset
  2110                                  
  2111                                  .done:
  2112                                  %endif
  2113                                  
  2114                                  
  2115                                  %if _IMMASM
  2116 00000351 FF16[0000]              	call near [ ia_restore ]
  2117                                  %endif
  2118                                  
  2119 00000355 F606[B901]10            	testopt [options7], opt7_no_ensure
  2120 0000035A 7503                    	jnz .skip
  2121                                  
  2122                                  %if _PM
  2123                                  	call ispm
  2124                                  	jz @F
  2125                                  %endif
  2126                                  %if !_LOADER
  2127 0000035C E80B11                  	call ensuredebuggeeloaded	; if no task is active, create a dummy one
  2128                                  %endif
  2129                                  %if _PM && 0
  2130                                  	jmp @FF
  2131                                  @@:
  2132                                  	testopt [internalflags], attachedterm
  2133                                  	jz @F
  2134                                  	mov dx, .message
  2135                                  	call putsz
  2136                                  
  2137                                  	usesection lDEBUG_DATA_ENTRY
  2138                                  .message:	ascizline "Attached term is set in PM!"
  2139                                  	usesection lDEBUG_CODE
  2140                                  %endif
  2141                                  @@:
  2142                                  .skip:
  2143                                  
  2144                                  
  2145                                  cmd3_continue_1_re:
  2146 0000035F BF[CE0A]                	mov di, line_out	; build prompt
  2147                                  %if _DEBUG
  2148                                   %if _DEBUG_COND
  2149 00000362 F606[ED01]01            	testopt [internalflags6], dif6_debug_mode
  2150 00000367 7403                    	jz @F
  2151                                   %endif
  2152 00000369 B07E                    	mov al, '~'		; indicate instance is to be debugged
  2153 0000036B AA                      	stosb
  2154                                  @@:
  2155                                  %endif
  2156                                  %if !_LOADER
  2157                                  %if _INDOS_PROMPT
  2158 0000036C E8C90F                  	call InDOS
  2159 0000036F 740F                    	jz @F
  2160                                   %if _BOOTLDR
  2161 00000371 F606[D901]40            	testopt [internalflags], nodosloaded
  2162                                  				; boot mode ?
  2163                                    %if _INDOS_PROMPT_NOBOOT
  2164 00000376 7508                    	jnz @F			; yes, do not show special prompt -->
  2165                                    %elif _INDOS_PROMPT_NOFLAG
  2166                                  	jnz .indos_prompt	; yes, show special prompt -->
  2167                                  				;  (do not call .real_indos check)
  2168                                    %endif
  2169                                   %endif
  2170                                   %if _INDOS_PROMPT_NOFLAG
  2171                                    %if _APPLICATION || _DEVICE
  2172                                  		; Never branches to here if bootloaded,
  2173                                  		;  so no need to handle only bootloaded.
  2174 00000378 E8CB0F                  	call InDOS.real_indos	; real InDOS set ?
  2175 0000037B 7403                    	jz @F			; no, do not show special prompt -->
  2176                                    %endif
  2177                                   %endif
  2178                                  .indos_prompt:
  2179 0000037D B021                    	mov al, '!'
  2180 0000037F AA                      	stosb
  2181                                  @@:
  2182                                  %endif
  2183                                  %endif
  2184                                  %if !_LOADER
  2185 00000380 B02D                    	mov al, '-'		; main prompt
  2186                                  %else
  2187                                  	mov al, '*'
  2188                                  %endif
  2189                                  %if _PM
  2190                                  	call ispm
  2191                                  	jnz .realmode
  2192                                  	mov al, '#'		; PM main prompt
  2193                                  .realmode:
  2194                                  %endif
  2195 00000382 F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2196 00000387 7402                    	jz @F
  2197 00000389 B026                    	mov al, '&'
  2198                                  @@:
  2199 0000038B F606[E301]01            	testopt [internalflags3], dif3_input_re
  2200 00000390 7402                    	jz @F
  2201 00000392 B025                    	mov al, '%'
  2202                                  @@:
  2203 00000394 AA                      	stosb
  2204                                  
  2205 00000395 C606[0000]00            	mov byte [hhflag], 0
  2206 0000039A 8326[0000]00            	and word [hh_depth], 0
  2207 0000039F 8326[0000]00            	and word [hh_depth_of_single_term], 0
  2208 000003A4 C706[840D][8805]        	mov word [getline_timer_func], dmycmd
  2209 000003AA 8026[DA01]FE            	clropt [internalflags], usecharcounter	; reset this automatically
  2210                                  
  2211 000003AF F606[E301]01            	testopt [internalflags3], dif3_input_re
  2212 000003B4 7515                    	jnz cmd3_continue_2_re
  2213                                  
  2214 000003B6 800E[D801]08            	setopt [internalflags], pagedcommand	; 2009-02-21: default to page all commands
  2215 000003BB 8026[DB01]CF            	clropt [internalflags], tt_silence | tt_silent_mode
  2216                                  				; reset, in case it's still set
  2217 000003C0 8126[DC01]3FF7          	clropt [internalflags2], dif2_tpg_proceed_bp_set | 			dif2_bp_failure | dif2_tpg_keep_proceed_bp, 1
  2219                                  %if _INPUT_FILE_HANDLES
  2220 000003C6 8026[DE01]DF            	clropt [internalflags2], dif2_closed_input_file
  2221                                  %endif
  2222                                  
  2223                                  cmd3_continue_2_re:
  2224 000003CB E83303                  	call determine_quiet_output
  2225                                  
  2226 000003CE 31C9                    	xor cx, cx
  2227 000003D0 870E[B40C]              	xchg cx, word [rc]	; reset rc
  2228 000003D4 890E[B60C]              	mov word [priorrc], cx	; make prior value available
  2229 000003D8 E304                    	jcxz @F
  2230 000003DA 890E[B80C]              	mov word [erc], cx	; update to last non-zero value
  2231                                  @@:
  2232                                  
  2233                                  %if !_LOADER
  2234                                  cmd3_check_relimit:
  2235 000003DE F606[E301]01            	testopt [internalflags3], dif3_input_re
  2236 000003E3 7425                    	jz cmd3_continue_not_re
  2237                                  
  2238 000003E5 8306[780B]01            	add word [re_count], 1
  2239 000003EA 8316[7A0B]00            	adc word [re_count + 2], 0
  2240 000003EF 8B16[7E0B]              	mov dx, word [re_limit + 2]
  2241 000003F3 A1[7C0B]                	mov ax, word [re_limit]
  2242 000003F6 3916[7A0B]              	cmp word [re_count + 2], dx
  2243 000003FA 7504                    	jne @F
  2244 000003FC 3906[780B]              	cmp word [re_count], ax
  2245                                  @@:
  2246                                  		; This branch bypasses cmd3_check_rclimit
  2247                                  		;  because RE buffer commands should not
  2248                                  		;  count towards the RC limit.
  2249 00000400 765C                    	jbe cmd3_continue_relimit_not_reached
  2250                                  
  2251 00000402 BA[0000]                	mov dx, msg.re_limit_reached
  2252 00000405 B84301                  	mov ax, 0143h
  2253 00000408 EB3D                    	jmp cmd3_check_common
  2254                                  
  2255                                  cmd3_continue_not_re:
  2256                                  %endif
  2257                                  
  2258                                  cmd3_check_rclimit:
  2259                                  
  2260                                  %if _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  2261                                  		; If executing from a script file then
  2262                                  		;  command doesn't count for RC limit.
  2263                                  %if _INPUT_FILE_BOOT
  2264 0000040A F606[DF01]02            	testopt [internalflags2], dif2_input_file_boot
  2265 0000040F 754D                    	jnz .file
  2266                                  %endif
  2267                                  %if _INPUT_FILE_HANDLES
  2268 00000411 E8240F                  	call InDOS
  2269 00000414 7507                    	jnz .file_not
  2270 00000416 F606[DE01]10            	testopt [internalflags2], dif2_input_file
  2271 0000041B 7541                    	jnz .file
  2272                                  %endif
  2273                                  .file_not:
  2274                                  
  2275                                  .file: equ cmd3_continue_rclimit_not_reached
  2276                                  %endif
  2277                                  
  2278 0000041D F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2279 00000422 743A                    	jz cmd3_continue_not_rc
  2280                                  
  2281 00000424 8306[800B]01            	add word [rc_count], 1
  2282 00000429 8316[820B]00            	adc word [rc_count + 2], 0
  2283 0000042E 8B16[860B]              	mov dx, word [rc_limit + 2]
  2284 00000432 A1[840B]                	mov ax, word [rc_limit]
  2285 00000435 3916[820B]              	cmp word [rc_count + 2], dx
  2286 00000439 7504                    	jne @F
  2287 0000043B 3906[800B]              	cmp word [rc_count], ax
  2288                                  @@:
  2289 0000043F 761D                    	jbe cmd3_continue_rclimit_not_reached
  2290                                  
  2291 00000441 BA[0000]                	mov dx, msg.rc_limit_reached
  2292 00000444 B84401                  	mov ax, 0144h
  2293                                  cmd3_check_common:
  2294 00000447 E8(0000)                	call putsz_error
  2295 0000044A E8DB0D                  	call setrc
  2296 0000044D 800E[E101]04            	setopt [internalflags3], dif3_at_line_end
  2297 00000452 A1[B40C]                	mov ax, word [rc]
  2298 00000455 A3[B60C]                	mov word [priorrc], ax
  2299 00000458 E8(0000)                	call getline_close_file
  2300 0000045B E9A2FB                  	jmp cmd3
  2301                                  
  2302                                  cmd3_continue_not_rc:
  2303                                  cmd3_continue_rclimit_not_reached:
  2304                                  cmd3_continue_relimit_not_reached:
  2305                                  
  2306                                  cmd3_check_line_out_overflow:
  2307 0000045E 813E[D60B]4226          	cmp word [line_out_overflow], 2642h
  2308 00000464 740C                    	je @F
  2309 00000466 C706[D60B]4226          	mov word [line_out_overflow], 2642h
  2310 0000046C BA[0000]                	mov dx, msg.line_out_overflow
  2311 0000046F E8(0000)                	call putsz_error
  2312                                  @@:
  2313                                  
  2314                                  cmd3_getline:
  2315                                  %if _EXTENSIONS
  2316 00000472 31C9                    	xor cx, cx
  2317 00000474 870E[4202]              	xchg cx, word [ext_inject_handler]
  2318 00000478 E303                    	jcxz cmd3_not_inject
  2319 0000047A E9(0000)                	jmp transfer_ext_cx
  2320                                  
  2321                                  cmd3_not_inject: section_of_function
  2322 0000047D 8B26[380C]              	mov sp, word [ savesp ]		; restore stack
  2323 00000481 E8(0000)                	call getline00		; prompted input, also resets linecounter
  2324                                  cmd3_injected: section_of_function
  2325 00000484 8B26[380C]              	mov sp, word [ savesp ]		; restore stack
  2326                                  
  2327                                  
  2328 00000488 8B0E[4002]              	mov cx, word [ext_preprocess_handler]
  2329 0000048C E303                    	jcxz cmd3_preprocessed
  2330 0000048E E9(0000)                	jmp transfer_ext_cx
  2331                                  
  2332                                  cmd3_preprocessed: section_of_function
  2333 00000491 16                      	push ss
  2334 00000492 1F                      	pop ds
  2335 00000493 16                      	push ss
  2336 00000494 07                      	pop es
  2337 00000495 8B26[380C]              	mov sp, word [ savesp ]		; restore stack
  2338                                  
  2339                                  
  2340 00000499 8B0E[3E02]              	mov cx, word [ext_command_handler]
  2341 0000049D E303                    	jcxz cmd3_not_ext
  2342 0000049F E9(0000)                	jmp transfer_ext_cx
  2343                                  
  2344                                  cmd3_not_ext: section_of_function
  2345 000004A2 16                      	push ss
  2346 000004A3 1F                      	pop ds
  2347 000004A4 16                      	push ss
  2348 000004A5 07                      	pop es
  2349 000004A6 8B26[380C]              	mov sp, word [ savesp ]		; restore stack
  2350 000004AA 4E                      	dec si
  2351 000004AB AC                      	lodsb
  2352                                  %else
  2353                                  	call getline00		; prompted input, also resets linecounter
  2354                                  cmd3_injected: section_of_function
  2355                                  %endif
  2356                                  
  2357 000004AC E8(0000)                	call iseol?.notsemicolon
  2358 000004AF 7518                    	jne cmd3_notblank
  2359 000004B1 F606[AB01]10            	testopt [options3], opt3_disable_autorepeat
  2360 000004B6 7508                    	jnz @F
  2361 000004B8 8B16[520D]              	mov dx, word [lastcmd]
  2362 000004BC 8804                    	mov byte [si], al
  2363 000004BE EB43                    	jmp short cmd4
  2364                                  
  2365                                  @@:
  2366 000004C0 C706[520D][8805]        	mov word [lastcmd], dmycmd
  2367 000004C6 E937FB                  	jmp cmd3
  2368                                  
  2369                                  cmd3_notblank:
  2370                                  %if _SYMBOLIC
  2371                                  	clropt [internalflags3], dif3_nosymbols_1
  2372                                  %endif
  2373 000004C9 C706[520D][8805]        	mov word [lastcmd], dmycmd
  2374 000004CF 3C3B                    	cmp al, ';'
  2375 000004D1 7437                    	je cmd3_j1		; if comment -->
  2376 000004D3 3C3A                    	cmp al, ':'
  2377 000004D5 7433                    	je cmd3_j1		; if jump label -->
  2378 000004D7 3C3F                    	cmp al, '?'
  2379 000004D9 7503E9C300              	je help			; if request for help -->
  2380 000004DE 3C2E                    	cmp al, '.'
  2381 000004E0 7503E9(0000)            	je immasm		; if assembling/immediate execution -->
  2382 000004E5 3C2D                    	cmp al, '-'
  2383 000004E7 7503                    	jne @F			; if not no symbol prefix -->
  2384                                  %if _SYMBOLIC
  2385                                  	setopt [internalflags3], dif3_nosymbols_1
  2386                                  %endif
  2387 000004E9 E8(0000)                	call skipwhite		; skip to next command letter
  2388                                  		; Empty line (autorepeat) not valid.
  2389                                  		; Comment not valid. Goto label not valid.
  2390                                  		; Help request not valid.
  2391                                  @@:
  2392 000004EC E8(0000)                	call capitalise
  2393 000004EF 2C41                    	sub al, 'A'
  2394                                  %if _SYMBOLIC
  2395                                  	cmp al, 'Z' - 'A'
  2396                                  	ja error		; if not recognised -->
  2397                                  	je @F			; if Z, do not commit -->
  2398                                  	nearcall zz_commit_insert	; if not Z, commit now
  2399                                  @@:
  2400                                  %else
  2401 000004F1 3C18                    	cmp al, 'Y' - 'A'
  2402 000004F3 7603E9DA0C              	ja error		; if not recognised -->
  2403                                  %endif
  2404 000004F8 98                      	cbw
  2405 000004F9 93                      	xchg bx, ax
  2406 000004FA E8(0000)                	call skipcomma
  2407 000004FD D1E3                    	shl bx, 1
  2408 000004FF 8B97[6E01]              	mov dx, word [ cmdlist+bx ]
  2409                                  cmd4:
  2410 00000503 BF[CE0A]                	mov di, line_out
  2411                                  %if _DEBUG || _LOADER
  2412 00000506 A8                      	db __TEST_IMM8		; (skip int3)
  2413                                  .int3:
  2414 00000507 CC                      	int3			; used by BU command
  2415                                  %endif
  2416 00000508 FFD2                    	call dx
  2417                                  cmd3_j1:
  2418 0000050A E9F3FA                  	jmp cmd3		; back to the top
  2419                                  
  2420                                  
  2421                                  %if !_LOADER
  2422                                  	code_insure_low_byte_not_0CCh
  2423                                  cmd2_reset_re_maybe_pm:
  2424                                  
  2425 0000050D 66                      	_386_o32		; mov esp
  2426 0000050E 8B26[380C]              	mov sp, word [ savesp ]		; restore stack
  2427 00000512 83E4FC                  _386	and sp, ~3			; align stack
  2428 00000515 66                      	_386_o32
  2429 00000516 31C0                    	xor ax, ax
  2430 00000518 66                      	_386_o32
  2431 00000519 50                      	push ax
  2432 0000051A 66                      	_386_o32
  2433 0000051B 9D                      	popf
  2434 0000051C 8B26[380C]              _386	mov sp, word [ savesp ]		; restore stack
  2435 00000520 FC                      	cld
  2436 00000521 FB                      	sti
  2437                                  
  2438                                  %if _PM
  2439                                  	call handle_mode_changed
  2440                                  %endif
  2441                                  %endif
  2442                                  
  2443                                  	code_insure_low_byte_not_0CCh
  2444                                  cmd2_reset_re:
  2445 00000522 8B1E[7C0D]              	mov bx, word [io_levels]
  2446                                  .entry_bx_levels:
  2447 00000526 31C9                    	xor cx, cx
  2448                                  .entry_bx_levels_cx_cmdline:
  2449 00000528 31D2                    	xor dx, dx
  2450                                  %if _INPUT_FILE_HANDLES
  2451 0000052A F606[DE01]10            	testopt [internalflags2], dif2_input_file
  2452 0000052F 7405                    	jz @F
  2453 00000531 030E[200C]              	add cx, word [input_file_handles.active]
  2454 00000535 41                      	inc cx
  2455                                  @@:
  2456                                  %endif
  2457                                  %if _INPUT_FILE_BOOT
  2458 00000536 F606[DF01]02            	testopt [internalflags2], dif2_input_file_boot
  2459 0000053B 7405                    	jz @F
  2460 0000053D 030E[0000]              	add cx, word [load_input_file.active]
  2461 00000541 41                      	inc cx
  2462                                  @@:
  2463                                  %endif
  2464                                  %if !_LOADER
  2465 00000542 F606[E301]01            	testopt [internalflags3], dif3_input_re
  2466 00000547 740D                    	jz @F
  2467 00000549 41                      	inc cx
  2468 0000054A 42                      	inc dx
  2469                                  		; Flag: If we abort anything (effective IOL >= 1)
  2470                                  		;  then we need to cancel RE buffer execution.
  2471                                  		;  This is so because RE execution is always the
  2472                                  		;  topmost command source, taking precedence over
  2473                                  		;  yy as well as RC buffer execution.
  2474 0000054B F606[7E0D]01            	testopt [io_flags], iof_extra_iol_for_tpg_re
  2475 00000550 7404                    	jz @F
  2476 00000552 43                      	inc bx
  2477 00000553 7501                    	jnz @F
  2478 00000555 4B                      	dec bx
  2479                                  @@:
  2480                                  %endif
  2481 00000556 F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2482 0000055B 740C                    	jz @F
  2483 0000055D 41                      	inc cx
  2484 0000055E F606[7E0D]02            	testopt [io_flags], iof_extra_iol_for_rc
  2485 00000563 7404                    	jz @F
  2486 00000565 43                      	inc bx
  2487 00000566 7501                    	jnz @F
  2488 00000568 4B                      	dec bx
  2489                                  @@:
  2490 00000569 39D9                    	cmp cx, bx
  2491 0000056B 7602                    	jbe @F
  2492 0000056D 89D9                    	mov cx, bx
  2493                                  @@:
  2494 0000056F E399                    	jcxz cmd3_j1			; IOL zero or nothing active -->
  2495 00000571 1E                      	push ds
  2496 00000572 07                      	pop es
  2497                                  @@:
  2498 00000573 51                      	push cx
  2499 00000574 52                      	push dx
  2500 00000575 E8(0000)                	call getline_close_file.resetstuff
  2501 00000578 5A                      	pop dx
  2502 00000579 59                      	pop cx
  2503 0000057A E2F7                    	loop @B
  2504                                  %if !_LOADER
  2505 0000057C 85D2                    	test dx, dx			; first cancelled was RE ?
  2506 0000057E 748A                    	jz cmd3_j1			; no, just proceed now -->
  2507 00000580 800E[A501]80            	setopt [options2], opt2_re_cancel_tpg
  2508                                  					; set to cancel command
  2509 00000585 E9(0000)                	jmp dumpregs_extended.exit	; clean up RE state
  2510                                  %else
  2511                                  	jmp cmd3_j1
  2512                                  %endif
  2513                                  
  2514                                  dmycmd:
  2515 00000588 C3                      	retn
  2516                                  
  2517                                  %if _EXTENSIONS
  2518                                  lastcmd_transfer_ext_entry:
  2519                                   %if _LINK
  2520 00000589 B9[0000]                	mov cx, eld_linkcall.call_cmd3
  2521                                   wlcalc word_minusext_eld_linkcall, equ $ - 2
  2522                                   %else
  2523                                  	mov cx, eld_linkcall.call_cmd3 - eld_linkcall
  2524                                   %endif
  2525 0000058C 51                      	push cx
  2526 0000058D 8B0E[540D]              	mov cx, word [lastcmd_transfer_ext_address]
  2527 00000591 E9(0000)                	jmp transfer_ext_cx
  2528                                  
  2529                                  near_transfer_ext_entry:
  2530 00000594 51                      	push cx
  2531 00000595 8B0E[560D]              	mov cx, word [near_transfer_ext_address]
  2532 00000599 E9(0000)                	jmp transfer_ext_cx
  2533                                  		; INP:	cx = entrypoint ip
  2534                                  		;	ss:sp -> original cx value, near return address
  2535                                  
  2536                                  		; INP:	ss:sp -> three words to discard, cx, near return
  2537                                  near_transfer_ext_return: section_of_function
  2538 0000059C 59                      	pop cx				; discard near return address
  2539 0000059D 59                      	pop cx
  2540 0000059E 59                      	pop cx				; discard far return address
  2541 0000059F 59                      	pop cx				; restore cx
  2542 000005A0 C3                      	retn				; return
  2543                                  %endif
  2544                                  
  2545                                  help:
  2546 000005A1 E8(0000)                	call skipcomma
  2547 000005A4 E8(0000)                	call capitalise
  2548                                  %if _EXTHELP
  2549                                   %if _COND
  2550 000005A7 BA[0000]                	mov dx, msg.condhelp
  2551 000005AA 3C43                    	cmp al, 'C'
  2552 000005AC 7503E98400              	je .spec
  2553                                   %endif
  2554                                   %if _OPTIONS
  2555 000005B1 3C4F                    	cmp al, 'O'
  2556 000005B3 7503E99E00              	je .options		; option help -->
  2557                                   %endif
  2558                                   %if _EXPRESSIONS
  2559 000005B8 BA[0000]                	mov dx, msg.expressionhelp
  2560 000005BB 3C45                    	cmp al, 'E'
  2561 000005BD 7476                    	je .spec
  2562                                   %endif
  2563                                  %endif
  2564                                  %if _EMS
  2565                                  	mov dx, msg.xhelp
  2566                                  	cmp al, 'X'
  2567                                  	je .spec
  2568                                  %endif
  2569 000005BF 4E                      	dec si
  2570                                   %if _BOOTLDR && _EXTHELPBOOT
  2571 000005C0 BA[0000]                	mov dx, msg.boot
  2572 000005C3 E8(0000)                	call isstring?
  2573 000005C6 BA[0000]                	mov dx, msg.boothelp
  2574                                    %if _LINK || _LINK_COMPAT
  2575                                  patch_boothelp_uncompressed: equ $ - 2
  2576                                    %endif
  2577 000005C9 746A                    	je .spec
  2578                                   %endif
  2579                                  %if _PM
  2580                                  	mov dx, msg.desc
  2581                                  	call isstring?
  2582                                  	mov dx, msg.deschelp
  2583                                  	je .spec
  2584                                  %endif
  2585                                  %if _EXTHELP
  2586 000005CB BA[0000]                	mov dx, msg.source
  2587 000005CE E8(0000)                	call isstring?
  2588 000005D1 BA[0000]                	mov dx, msg.help_source
  2589 000005D4 745F                    	je .spec
  2590                                  %endif
  2591                                  %if !_LOADER
  2592 000005D6 BA[0000]                	mov dx, msg.re
  2593 000005D9 E8(0000)                	call isstring?
  2594 000005DC BA[0000]                	mov dx, msg.help_re
  2595 000005DF 7454                    	je .spec
  2596 000005E1 BA[0000]                	mov dx, msg.run
  2597 000005E4 E8(0000)                	call isstring?
  2598 000005E7 BA[0000]                	mov dx, msg.help_run
  2599 000005EA 7449                    	je .spec
  2600                                  %endif
  2601 000005EC BA[0000]                	mov dx, msg.string_version
  2602 000005EF E8(0000)                	call isstring?
  2603 000005F2 BB[0000]                	mov bx, msg.build_array
  2604 000005F5 B9[0000]                	mov cx, msg.build_version_amount
  2605 000005F8 744D                    	je .spec_multi
  2606 000005FA BA[0000]                	mov dx, msg.string_build
  2607 000005FD E8(0000)                	call isstring?
  2608                                   %if _LINK_COMPAT
  2609 00000600 B9[0000]                	mov cx, msg.build_short_amount
  2610                                   %else
  2611                                  	mov cl, msg.build_short_amount
  2612                                   %endif
  2613 00000603 7442                    	je .spec_multi
  2614 00000605 AC                      	lodsb
  2615 00000606 E8(0000)                	call capitalise
  2616                                   %if _LINK_COMPAT
  2617 00000609 B9[0000]                	mov cx, msg.build_long_amount
  2618                                   %else
  2619                                  	mov cl, msg.build_long_amount
  2620                                   %endif
  2621 0000060C 3C42                    	cmp al, 'B'
  2622 0000060E 7437                    	je .spec_multi		; build info -->
  2623                                  %if _EXTHELP
  2624 00000610 BA[0000]                	mov dx, msg.license
  2625 00000613 3C4C                    	cmp al, 'L'
  2626 00000615 741E                    	je .spec		; licence -->
  2627 00000617 BA[0000]                	mov dx, msg.flaghelp
  2628 0000061A 3C46                    	cmp al, 'F'
  2629 0000061C 7417                    	je .spec		; flag help -->
  2630 0000061E BA[0000]                	mov dx, msg.reghelp
  2631 00000621 3C52                    	cmp al, 'R'
  2632 00000623 7410                    	je .spec		; register help -->
  2633                                   %if _VARIABLES || _OPTIONS || _PSPVARIABLES
  2634 00000625 BA[0000]                	mov dx, msg.varhelp
  2635 00000628 3C56                    	cmp al, 'V'
  2636 0000062A 7409                    	je .spec		; variable help -->
  2637                                   %endif
  2638                                  %endif
  2639 0000062C BB[0000]                	mov bx, msg.help_array	; default help
  2640                                   %if _LINK_COMPAT
  2641 0000062F B9[0000]                	mov cx, msg.help_array_amount
  2642                                   %else
  2643                                  	mov cl, msg.help_array_amount
  2644                                   %endif
  2645 00000632 4E                      	dec si
  2646 00000633 EB12                    	jmp .spec_multi
  2647                                  
  2648                                  .spec:
  2649 00000635 AC                      	lodsb
  2650 00000636 E8(0000)                	call chkeol
  2651                                  %if _MESSAGESEGMENT || _HELP_COMPRESSED
  2652 00000639 E8(0000)                	call putsz_exthelp
  2653 0000063C EB03                    	jmp cmd3_j1a
  2654                                  %endif
  2655                                  
  2656                                  prnquit:
  2657 0000063E E8(0000)                	call putsz		; print string
  2658                                  cmd3_j1a:
  2659 00000641 E9C6FE                  	jmp cmd3_j1		; done
  2660                                  
  2661 00000644 E98B0B                  errorj1:jmp error
  2662                                  
  2663                                  help.spec_multi:
  2664 00000647 AC                      	lodsb
  2665 00000648 E8(0000)                	call chkeol
  2666                                  .loop:
  2667 0000064B 8B17                    	mov dx, word [bx]
  2668 0000064D E8(0000)                	call putsz_exthelp
  2669 00000650 43                      	inc bx
  2670 00000651 43                      	inc bx
  2671 00000652 E2F7                    	loop .loop
  2672 00000654 EBEB                    	jmp short cmd3_j1a
  2673                                  
  2674                                  %if _EXTHELP && _OPTIONS
  2675                                  help.options:
  2676 00000656 89F3                    	mov bx, si
  2677 00000658 E8(0000)                	call skipwhite
  2678 0000065B E8(0000)                	call iseol?
  2679 0000065E 7445                    	je .all
  2680 00000660 E8(0000)                	call capitalise
  2681 00000663 3C41                    	cmp al, 'A'
  2682 00000665 BA[0000]                	mov dx, msg.asmoptions_1
  2683 00000668 7429                    	je .single
  2684 0000066A 3C49                    	cmp al, 'I'
  2685 0000066C BA[0000]                	mov dx, msg.flags_1
  2686 0000066F 7422                    	je .single
  2687 00000671 BF[0000]                	mov di, msg.options_scan
  2688 00000674 B9[0000]                	mov cx, msg.options_scan_amount
  2689 00000677 F2AE                    	repne scasb
  2690 00000679 751A                    	jne .pages
  2691 0000067B 81EF[0100]              	sub di, msg.options_scan + 1
  2692 0000067F D1E7                    	shl di, 1
  2693 00000681 8BBD[0000]              	mov di, word [msg.options_array + di]
  2694 00000685 89FA                    	mov dx, di
  2695                                  %if _MESSAGESEGMENT
  2696 00000687 1E                      	push ds
  2697                                   %if _PM
  2698                                  	call get_messagesegsel
  2699                                   %else
  2700 00000688 368E1E[2202]             	mov ds, word [ss:messageseg]
  2701                                   %endif
  2702                                   %if _HELP_COMPRESSED
  2703 0000068D 833D05                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2704                                   %else
  2705                                  	cmp byte [di], 0
  2706                                   %endif
  2707 00000690 1F                      	pop ds
  2708                                  %else
  2709                                   %if _HELP_COMPRESSED
  2710                                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2711                                   %else
  2712                                  	cmp byte [di], 0
  2713                                   %endif
  2714                                  %endif
  2715 00000691 74B1                    	je errorj1
  2716                                  .single:
  2717 00000693 EBA0                    	jmp help.spec
  2718                                  
  2719                                  .pages:
  2720 00000695 8D77FF                  	lea si, [bx - 1]
  2721 00000698 BA[0000]                	mov dx, msg.string_options
  2722 0000069B E8(0000)                	call isstring?
  2723 0000069E 75A4                    	jne errorj1
  2724 000006A0 BA[0000]                	mov dx, msg.options_pages
  2725 000006A3 EBEE                    	jmp .single
  2726                                  
  2727                                  .all:
  2728 000006A5 BB[0000]                	mov bx, msg.options_array
  2729 000006A8 B9[0000]                	mov cx, msg.options_array_amount
  2730                                  .loop:
  2731 000006AB 8B3F                    	mov di, word [bx]
  2732 000006AD 8B17                    	mov dx, word [bx]
  2733 000006AF E8(0000)                	call putsz_exthelp
  2734 000006B2 43                      	inc bx
  2735 000006B3 43                      	inc bx
  2736                                  %if _MESSAGESEGMENT
  2737 000006B4 1E                      	push ds
  2738                                   %if _PM
  2739                                  	call get_messagesegsel
  2740                                   %else
  2741 000006B5 368E1E[2202]             	mov ds, word [ss:messageseg]
  2742                                   %endif
  2743                                   %if _HELP_COMPRESSED
  2744 000006BA 833D05                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2745                                   %else
  2746                                  	cmp byte [di], 0
  2747                                   %endif
  2748 000006BD 1F                      	pop ds
  2749                                  %else
  2750                                   %if _HELP_COMPRESSED
  2751                                  	cmp word [di], 2 + !!_LZEXEDAT * 3
  2752                                   %else
  2753                                  	cmp byte [di], 0
  2754                                   %endif
  2755                                  %endif
  2756 000006BE 740B                    	je @F
  2757 000006C0 83F901                  	cmp cx, 1
  2758 000006C3 7406                    	je @F
  2759 000006C5 BA[0000]                	mov dx, crlf
  2760 000006C8 E8(0000)                	call putsz
  2761                                  @@:
  2762 000006CB E2DE                    	loop .loop
  2763 000006CD E930F9                  	jmp cmd3
  2764                                  %endif
  2765                                  
  2766                                  
  2767                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT2D || _CATCHINT08 || _LOADER
  2770                                  		; INP:	ds:si -> IISP entry header
  2771                                  		;	al = interrupt number
  2772                                  		;	bx = interrupt hooked status flag (dif4 low word)
  2773                                  		; OUT:	-
  2774                                  		; CHG:	ax, bx, cx, dx, di, si
  2775                                  cmd3_int_enable.set_bx_to_dx:
  2776 000006D0 89D3                    	mov bx, dx
  2777                                  
  2778                                  cmd3_int_enable:
  2779 000006D2 851E[E401]              	test word [internalflags4], bx
  2780 000006D6 750C                    	jnz .ret
  2781                                  
  2782                                  .need:
  2783 000006D8 53                      	push bx
  2784 000006D9 E8(0000)                	call install_86m_interrupt_handler
  2785 000006DC 5B                      	pop bx
  2786 000006DD 091E[E401]              	or word [internalflags4], bx
  2787 000006E1 E8(0000)                	call update_inttab_optional
  2788                                  .ret:
  2789 000006E4 C3                      	retn
  2790                                  %endif
  2791                                  
  2792                                  
  2793                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT2D || _CATCHINT08 || _PM || _LOADER
  2796                                  		; INP:	ds:si -> IISP entry header
  2797                                  		;	al = interrupt number
  2798                                  		;	dx = interrupt unhook force flag (dif4 high word)
  2799                                  		;	bx = interrupt hooked status flag (dif4 low word)
  2800                                  		; OUT:	NC if successfully unhooked
  2801                                  		;	 dif4 low word cleared
  2802                                  		;	CY if already unhooked or failed to unhook,
  2803                                  		;	 ZR if already unhooked
  2804                                  		;	  (dif4 low word is clear)
  2805                                  		;	 NZ if failed to unhook
  2806                                  		;	  (dif4 low word is still set)
  2807                                  		; CHG:	ax, bx, di, si
  2808                                  cmd3_int_disable.set_bx_to_dx:
  2809 000006E5 89D3                    	mov bx, dx
  2810                                  
  2811                                  cmd3_int_disable:
  2812 000006E7 851E[E401]              	test word [internalflags4], bx
  2813 000006EB 7412                    	jz .ret_CY		; --> (ZR)
  2814                                  
  2815 000006ED E8(0000)                	call UnhookInterruptForce
  2816 000006F0 720B                    	jc .ret_CY_NZ
  2817                                  
  2818 000006F2 F7D3                    	not bx
  2819 000006F4 211E[E401]              	and word [internalflags4], bx
  2820 000006F8 E8(0000)                	call update_inttab_optional
  2821 000006FB F8                      	clc			; (NC)
  2822 000006FC C3                      	retn
  2823                                  
  2824                                  .ret_CY_NZ:
  2825 000006FD 85E4                    	test sp, sp		; (NZ)
  2826                                  .ret_CY:
  2827 000006FF F9                      	stc			; (CY)
  2828 00000700 C3                      	retn
  2829                                  %endif
  2830                                  
  2831                                  
  2832                                  determine_quiet_output:
  2833 00000701 8026[E101]EF            	clropt [internalflags3], dif3_quiet_output
  2834                                  
  2835 00000706 57                      	push di
  2836 00000707 50                      	push ax
  2837 00000708 F606[E301]01            	testopt [internalflags3], dif3_input_re
  2838 0000070D 7549                    	jnz .notquiet
  2839                                  
  2840                                  %if _INPUT_FILE_BOOT
  2841 0000070F F606[DF01]02            	testopt [internalflags2], dif2_input_file_boot
  2842 00000714 7412                    	jz @F
  2843 00000716 B8A000                  	mov ax, LOAD_INPUT_FILE_SIZE
  2844 00000719 52                      	push dx
  2845 0000071A F726[0000]              	mul word [load_input_file.active]
  2846 0000071E 5A                      	pop dx
  2847 0000071F 89C7                    	mov di, ax
  2848 00000721 F685[2700]80            	testopt [load_input_file + di - LOADDATA3 + ldFATType], ifhfQuietOutput
  2849 00000726 EB29                    	jmp .quiet_if_nz
  2850                                  
  2851                                  @@:
  2852                                  %endif
  2853                                  %if _INPUT_FILE_HANDLES
  2854 00000728 E80D0C                  	call InDOS
  2855 0000072B 7518                    	jnz @F
  2856                                  
  2857 0000072D F606[DE01]10            	testopt [internalflags2], dif2_input_file
  2858 00000732 7411                    	jz @F
  2859 00000734 8B3E[200C]              	mov di, word [input_file_handles.active]
  2860 00000738 D1E7                    	shl di, 1
  2861 0000073A D1E7                    	shl di, 1
  2862 0000073C D1E7                    	shl di, 1		; to qword array index
  2863                                   %if INPUTFILEHANDLE_size != 8
  2864                                    %error Unexpected structure size
  2865                                   %endif
  2866 0000073E F685[A30B]80            	testopt [input_file_handles + di + ifhFlags], ifhfQuietOutput
  2867 00000743 EB0C                    	jmp .quiet_if_nz
  2868                                  
  2869                                  @@:
  2870                                  %endif
  2871 00000745 F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2872 0000074A 740C                    	jz @F
  2873 0000074C F606[A301]80            	testopt [options], opt_cmdline_quiet_output
  2874                                  	; jmp .quiet_if_nz
  2875                                  
  2876                                  .quiet_if_nz:
  2877 00000751 7405                    	jz @F
  2878                                  .quiet:
  2879 00000753 800E[E101]10            	setopt [internalflags3], dif3_quiet_output
  2880                                  .notquiet:
  2881                                  @@:
  2882 00000758 58                      	pop ax
  2883 00000759 5F                      	pop di
  2884 0000075A C3                      	retn
  2885                                  
  2886                                  
  2887                                  guard_auxbuff.1_or_2:
  2888 0000075B F606[E301]30            	testopt [internalflags3], dif3_auxbuff_guarded_1 		| dif3_auxbuff_guarded_2
  2890 00000760 EB05                    	jmp @F
  2891                                  
  2892                                  guard_auxbuff: section_of_function
  2893 00000762 F606[E301]70            	testopt [internalflags3], dif3_auxbuff_guarded_1 		| dif3_auxbuff_guarded_2 		| dif3_auxbuff_guarded_3
  2896                                  @@:
  2897 00000767 7506                    	jnz @F
  2898 00000769 800E[E301]10            	setopt [internalflags3], dif3_auxbuff_guarded_1
  2899 0000076E C3                      	retn
  2900                                  
  2901                                  @@:
  2902 0000076F B80101                  	mov ax, 0101h
  2903 00000772 E8B30A                  	call setrc
  2904 00000775 BA[0000]                	mov dx, msg.guard_auxbuff_error
  2905                                  .putsz_error:
  2906 00000778 E8(0000)                	call putsz
  2907 0000077B E982F8                  	jmp cmd3
  2908                                  
  2909                                  
  2910                                  		; This is used to disallow commands
  2911                                  		;  while reading from the RE buffer.
  2912                                  guard_re: section_of_function
  2913                                  %if !_LOADER
  2914 0000077E F606[E301]01            	testopt [internalflags3], dif3_input_re
  2915 00000783 7501                    	jnz @F
  2916 00000785 C3                      	retn
  2917                                  
  2918                                  @@:
  2919 00000786 BA[0000]                	mov dx, msg.guard_re_error
  2920 00000789 EB0B                    	jmp guard_rc.specificerror102
  2921                                  %else
  2922                                  	retn
  2923                                  %endif
  2924                                  
  2925                                  		; This is used to disallow commands
  2926                                  		;  while reading from the RC buffer.
  2927                                  guard_rc:
  2928 0000078B F606[E101]01            	testopt [internalflags3], dif3_input_cmdline
  2929 00000790 7501                    	jnz @F
  2930 00000792 C3                      	retn
  2931                                  
  2932                                  @@:
  2933 00000793 BA[0000]                	mov dx, msg.guard_rc_error
  2934                                  .specificerror102:
  2935 00000796 B80201                  	mov ax, 0102h
  2936 00000799 E88C0A                  	call setrc
  2937 0000079C EBDA                    	jmp guard_auxbuff.putsz_error
  2938                                  
  2939                                  
  2940                                  %if _EXTENSIONS
  2941                                  	usesection lDEBUG_DATA_ENTRY
  2941          ------------------       note: usesection lDEBUG_DATA_ENTRY
  2942                                  	align 2, db 0
  2943                                  linkcall_table:
  2944 000013D8 0000                    .init:	dw 0
  2945 000013DA 0400                    	dw (.end - .) / 2
  2946                                  .:
  2947 000013DC 0000                    	dw 0
  2948 000013DE 0000                    .code1:	dw 0
  2949                                   %if _DUALCODE
  2950                                  	dw 1
  2951                                  .code2:	dw 0
  2952                                   %endif
  2953 000013E0 0200                    	dw 2
  2954 000013E2 0000                    .entry:	dw 0
  2955                                  .end:
  2956                                  
  2957                                  		; INP:	_PM=0: ss:sp -> dword far return address
  2958                                  		;	_PM=1: ss:sp -> word near return address
  2959                                  		;		followed by an uninitialised placeholder word
  2960                                  		; CHG:	- (not even flags)
  2961                                  entry_ret_to_ext:
  2962                                   %if _PM
  2963                                  	call entry_to_code_segsel
  2964                                  	dw code_ret_to_ext
  2965                                   %else
  2966 000013E4 CB                      	retf		; simple
  2967                                   %endif
  2968                                  
  2969                                  
  2970                                  	usesection lDEBUG_CODE
  2970          ------------------       note: usesection lDEBUG_CODE
  2971                                   %if _DUALCODE && _PM
  2972                                  		; INP:	ss:sp -> dword dual call return address (to discard)
  2973                                  		;	ss:sp + 4 -> word near return address
  2974                                  		;		followed by an uninitialised placeholder word
  2975                                  		; CHG:	- (not even flags)
  2976                                  dualfunction
  2977                                  code2_to_code_ret_to_ext: section_of_function
  2978                                  	lframe 0
  2979                                  	lpar word, dualseg
  2980                                  	lpar word, dualofs
  2981                                  	lenter
  2982                                  	push word [bp + ?frame_bp]
  2983                                  	pop word [bp + ?dualseg]
  2984                                  	lleave ctx
  2985                                  	pop bp			; (discard)
  2986                                  	pop bp			; (discard)
  2987                                  	pop bp			; restore bp
  2988                                  		; fall through to code_ret_to_ext
  2989                                   %endif
  2990                                  
  2991                                  		; INP:	_PM=0: ss:sp -> dword far return address
  2992                                  		;	_PM=1: ss:sp -> word near return address
  2993                                  		;		followed by an uninitialised placeholder word
  2994                                  		; CHG:	- (not even flags)
  2995                                  code_ret_to_ext:
  2996                                   %if _PM
  2997                                  		; ss:sp -> word near return address, placeholder word
  2998                                  	lframe 0
  2999                                  	lpar word, retseg
  3000                                  	lpar word, retofs
  3001                                  	lenter
  3002                                  	push di
  3003                                  	mov di, word [ss:pm_2_86m_0]
  3004                                    %if extseg + 2 != extcssel
  3005                                     %error code_ret_to_ext expects extcssel after extseg
  3006                                    %endif
  3007                                  	push word [ss:extseg + di]
  3008                                  	pop word [bp + ?retseg]
  3009                                  	pop di
  3010                                  	lleave , optimiserestoresp
  3011                                   %endif
  3012                                  code_retf: section_of_function
  3013 0000079E CB                      	retf			; now return to ext
  3014                                  
  3015                                   %if _DUALCODE
  3016                                  	usesection lDEBUG_CODE2
  3017                                  code2_ret_to_ext:
  3018                                    %if _PM
  3019                                  	dualcall code2_to_code_ret_to_ext
  3020                                    %else
  3021                                  	retf			; simple case if _PM=0
  3022                                    %endif
  3023                                   %endif
  3024                                  %endif
  3025                                  
  3026                                  %ifn _EXTENSIONS
  3027                                  code_retf: section_of_function
  3028                                  	retf
  3029                                  %endif
  3030                                  
  3031                                  %ifn _LINK_COMPAT
  3032                                   %ifn _LINK
  3033                                  %include "amis.asm"
  3034                                   %endif
  3035                                  
  3036                                  	usesection lDEBUG_CODE
  3037                                  
  3038                                  %if _DEBUG4 || _DEBUG5
  3039                                  %define _DEB_ASM_PREFIX
  3040                                  %include "deb.asm"
  3041                                  %endif
  3042                                  
  3043                                  
  3044                                   %ifn _LINK
  3045                                  %if !_LOADER
  3046                                  %include "aa.asm"
  3047                                  %endif
  3048                                  %include "dd.asm"
  3049                                  %if _RN
  3050                                   %imacro internaldatarelocation 0-*.nolist
  3051                                   %endmacro
  3052                                   %include "fptostr.asm"
  3053                                   %unimacro internaldatarelocation 0-*.nolist
  3054                                  %endif
  3055                                  %include "run.asm"
  3056                                  %include "install.asm"
  3057                                  %include "uu.asm"
  3058                                  %if _IMMASM
  3059                                  %include "immasm.asm"
  3060                                  %else
  3061                                  immasm:
  3062                                  	lodsb
  3063                                  	call chkeol
  3064                                  	jmp cmd3
  3065                                  %endif
  3066                                  %if _HELP_COMPRESSED
  3067                                  	overridedef STANDALONE, 0
  3068                                  %include "helpdepk.asm"
  3069                                  	resetdef STANDALONE
  3070                                  %endif
  3071                                   %endif
  3072                                  %else		; _LINK_COMPAT
  3073                                  %if _DEBUG4 || _DEBUG5
  3074                                  %define _DEB_ASM_PREFIX
  3075                                  %include "deb.asm"
  3076                                  %endif
  3077                                  %endif		; _LINK_COMPAT
  3078                                  
  3079                                  	usesection lDEBUG_DATA_ENTRY
  3079          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3080                                  
  3081                                  %if _PM || _CATCHINT07 || _CATCHINT0C || _CATCHINT0D
  3082 000013E5 00<rep 3h>              	align 4, db 0
  3083 000013E8 00000000                exception_csip:	dd 0	; 16:16 far 16-bit address of debugger exception
  3084                                   %if _AREAS
  3085 000013EC 0000<rep 4h>            exception_stack:times 4 dw 0
  3086                                  			; stack of debugger exception
  3087                                   %endif
  3088                                  %endif
  3089                                  
  3090                                  %if _PM
  3091                                   %ifn _LINK || _LINK_COMPAT
  3092                                  %include "pmdata.asm"
  3093                                  %include "pminit.asm"
  3094                                  %include "pmentry.asm"
  3095                                   %endif
  3096                                  
  3097                                  
  3098                                  	usesection lDEBUG_CODE
  3099                                  
  3100                                  subcpu 286
  3101                                  resetmode_and_test_d_b_bit: section_of_function
  3102                                  %if _PM
  3103                                  	call resetmode
  3104                                  %endif
  3105                                  
  3106                                  		; Test if bx is a 32-bit selector
  3107                                  		;  (as opposed to a 16-bit selector or a segment)
  3108                                  		;
  3109                                  		; INP:	bx = selector (PM) or segment (86M)
  3110                                  		; OUT:	NZ = 32-bit
  3111                                  		;	ZR = 16-bit (always if 86M)
  3112                                  		;	NC
  3113                                  		; REM:	This checks whether a code segment's D bit or
  3114                                  		;	 a stack segment's B bit is set. This operation
  3115                                  		;	 is not meaningful otherwise.
  3116                                  test_d_b_bit: section_of_function
  3117                                  _386	call ispm
  3118                                  _386	jz .pm				; 386 and PM, check selector -->
  3119                                  		; not PM or no 386
  3120                                  .ZR:
  3121                                  	cmp al, al			; ZR, NC
  3122                                  	retn
  3123                                  .pm:
  3124                                  [cpu 386]
  3125                                  	push eax
  3126                                  	xor eax, eax			; use rights = 0 if inaccessible
  3127                                  	lar eax, ebx			; access rights
  3128                                  		; eax is unchanged if the access rights are inaccessible
  3129                                  		;  (and NZ is set in that case)
  3130                                  	test eax, 400000h		; test bit (NC)
  3131                                  	pop eax
  3132                                  	retn
  3133                                  __CPU__
  3134                                  
  3135                                  
  3136                                  		; Test if selector in bx has a limit beyond 64 KiB - 1 B
  3137                                  		;
  3138                                  		; INP:	bx = selector (PM) or segment (86M)
  3139                                  		; OUT:	NZ = limit above 64 KiB - 1 B
  3140                                  		;	ZR = limit below 64 KiB (always if 86M)
  3141                                  		;	NC
  3142                                  test_high_limit: section_of_function
  3143                                  _386	call ispm
  3144                                  _386	jz .pm				; 386 and PM, check selector -->
  3145                                  		; not PM or no 386
  3146                                  	jmp test_d_b_bit.ZR
  3147                                  
  3148                                  .pm:
  3149                                  [cpu 386]
  3150                                  	push eax
  3151                                  	xor eax, eax			; use limit = 0 if inaccessible
  3152                                  	lsl eax, ebx			; segment limit
  3153                                  		; eax is unchanged if the segment limit is inaccessible
  3154                                  		;  (and NZ is set in that case)
  3155                                  	test eax, 0FFFF_0000h		; (NC) ZR if low limit, else NZ
  3156                                  	pop eax
  3157                                  	retn
  3158                                  __CPU__
  3159                                  
  3160                                  subcpureset	; subcpu used in pminit.asm (!_LINK)
  3161                                  %endif	; _PM
  3162                                  
  3163                                  %if _NOEXTENDER
  3164                                  		; When we support non-extended DPMI, some calls to Int21
  3165                                  		; are (extended) Int21 calls and some are (not extended)
  3166                                  		; calls down to the real mode Int21. doscall is a macro
  3167                                  		; that will always call the non-extended Int21.
  3168                                  
  3169                                  		; Execute a non-extended DOS call
  3170                                  _doscall: section_of_function
  3171                                  	push di
  3172                                  	mov di, word [ss:pm_2_86m_0]
  3173                                  	jmp near word [ss:.table + di]
  3174                                  
  3175                                  	usesection lDEBUG_DATA_ENTRY
  3176                                  		; REM:	Dispatch table in section lDEBUG_CODE
  3177                                  	align 2, db 0
  3178                                  .table:
  3179                                  	dw .86m_pop
  3180                                  	dw .pm_pop
  3181                                  
  3182                                  	usesection lDEBUG_CODE
  3183                                  .pm_pop:
  3184                                  	pop di
  3185                                  subcpu 286
  3186                                  		; Execute a non-extended DOS call from PM
  3187                                  .pm:
  3188                                  	push word [ss:pspdbg]
  3189                                  	push 21h
  3190                                  	call intcall
  3191                                  	retn
  3192                                  subcpureset
  3193                                  .86m_pop:
  3194                                  	pop di
  3195                                  	jmp _int21
  3196                                  %endif
  3197                                  
  3198                                  
  3199                                  %if _DUALCODE
  3200                                  %push
  3201                                  %assign %$counter 0
  3202                                  
  3203                                  %rep 2
  3204                                  
  3205                                  %if %$counter == 0
  3206                                  %define %$currentindex 0
  3207                                  %define %$currentname lDEBUG_CODE
  3208                                  %define %$othername lDEBUG_CODE2
  3209                                  %define %$othersegvar code2_seg
  3210                                  %define %$otherselvar code2_sel
  3211                                  %else
  3212                                  %define %$currentindex 1
  3213                                  %define %$currentname lDEBUG_CODE2
  3214                                  %define %$othername lDEBUG_CODE
  3215                                  %define %$othersegvar code_seg
  3216                                  %define %$otherselvar code_sel
  3217                                  %endif
  3218                                  
  3219                                  	hiddenusesection %$currentname
  3220                                  %if _PM
  3221                                  %$currentname %+ _to_ %+ %$currentname %+ _dualcall_helper:
  3222                                  	push ax		; placeholder
  3223                                  	push ax		; chain
  3224                                  	lframe 0
  3225                                  	lpar word,	offset_segment
  3226                                  	lpar word,	placeholder
  3227                                  	lpar word,	chain
  3228                                  	lenter
  3229                                  	push bx
  3230                                  	mov bx, word [bp + ?offset_segment]
  3231                                  %if _DEBUG
  3232                                  	mov word [bp + ?placeholder], bx
  3233                                  	push word [cs:bx + 2]
  3234                                  %else
  3235                                  	push word [cs:bx]
  3236                                  	lea bx, [bx + 2]
  3237                                  	mov word [bp + ?placeholder], bx
  3238                                  %endif
  3239                                  	pop word [bp + ?chain]
  3240                                  	mov word [bp + ?offset_segment], %$$currentindex
  3241                                  	pop bx
  3242                                  	lleave
  3243                                  	retn
  3244                                  
  3245                                  %$currentname %+ _to_ %+ %$othername %+ _dualcall_helper:
  3246                                  	push ax		; placeholder
  3247                                  	push ax		; chain
  3248                                  	push ax		; chain
  3249                                  	lframe 0
  3250                                  	lpar word,	offset_segment
  3251                                  	lpar word,	placeholder
  3252                                  	lpar dword,	chain
  3253                                  	lenter
  3254                                  	push bx
  3255                                  	mov bx, word [bp + ?offset_segment]
  3256                                  %if _DEBUG
  3257                                  	mov word [bp + ?placeholder], bx
  3258                                  	push word [cs:bx + 2]
  3259                                  %else
  3260                                  	push word [cs:bx]
  3261                                  	lea bx, [bx + 2]
  3262                                  	mov word [bp + ?placeholder], bx
  3263                                  %endif
  3264                                  	pop word [bp + ?chain]
  3265                                  	mov bx, word [ss:pm_2_86m_0]
  3266                                  %if %$$othersegvar + 2 != %$$otherselvar
  3267                                   %error Expected sel variable after seg variable
  3268                                  %endif
  3269                                  	mov bx, word [ss:%$$othersegvar + bx]
  3270                                  	mov word [bp + ?chain + 2], bx
  3271                                  	mov word [bp + ?offset_segment], %$$currentindex
  3272                                  	pop bx
  3273                                  	lleave
  3274                                  	retf
  3275                                  
  3276                                  
  3277                                  %$currentname %+ _dualret_helper:
  3278                                  	lframe near
  3279                                  	lpar word,	index_segment
  3280                                  	lpar word,	offset
  3281                                  	lpar_return
  3282                                  	lenter
  3283                                  	push bx
  3284                                  	push di
  3285                                  
  3286                                  %if code_seg + 2 != code_sel
  3287                                   %error Unexpected layout
  3288                                  %endif
  3289                                  %if code2_seg + 2 != code2_sel
  3290                                   %error Unexpected layout
  3291                                  %endif
  3292                                  	mov bx, word [bp + ?index_segment]
  3293                                  	mov bl, byte [ss:.table + bx]	; multiply without fl change
  3294                                  	mov di, word [ss:pm_2_86m_0]
  3295                                  	mov bx, word [ss:code_seg + bx + di]
  3296                                  	mov word [bp + ?index_segment], bx
  3297                                  	pop di
  3298                                  	pop bx
  3299                                  	lleave
  3300                                  	lret
  3301                                  
  3302                                  	usesection lDEBUG_DATA_ENTRY
  3303                                  .table:
  3304                                  	db 0
  3305                                  	db code2_seg - code_seg
  3306                                  
  3307                                  	hiddenusesection %$currentname
  3308                                  %endif
  3309                                  
  3310                                  
  3311                                  %ifn _DUALCODE && ! _PM && _DUALCODENEARDUAL
  3312                                  %$currentname %+ _to_ %+ %$othername %+ _nearcall_helper:
  3313                                  	push ax		; return_offset
  3314                                  	push ax		; placeholder
  3315                                  	push ax		; chain
  3316                                  	push ax		; chain
  3317                                  	lframe 0
  3318                                  	lpar word,	offset_segment
  3319                                  	lpar word,	return_offset	; far return
  3320                                  	lpar word,	placeholder	; near return
  3321                                  	lpar dword,	chain		; far target address
  3322                                  	lenter
  3323                                  	push bx
  3324                                  	mov bx, word [bp + ?offset_segment]
  3325                                  %if _DEBUG
  3326                                  	mov word [bp + ?return_offset], bx
  3327                                  	push word [cs:bx + 2]
  3328                                  %else
  3329                                  	push word [cs:bx]
  3330                                  	lea bx, [bx + 2]
  3331                                  	mov word [bp + ?return_offset], bx
  3332                                  %endif
  3333                                  	pop word [bp + ?chain]
  3334                                  
  3335                                  %if _PM
  3336                                  	mov bx, word [ss:pm_2_86m_0]
  3337                                  %if %$$othersegvar + 2 != %$$otherselvar
  3338                                   %error Expected sel variable after seg variable
  3339                                  %endif
  3340                                  	mov bx, word [ss:%$$othersegvar + bx]
  3341                                  %else
  3342                                  	mov bx, word [ss:%$$othersegvar]
  3343                                  %endif
  3344                                  	mov word [bp + ?chain + 2], bx
  3345                                  %if _PM
  3346                                  	mov word [bp + ?offset_segment], %$$currentindex
  3347                                  %else
  3348                                  	mov word [bp + ?offset_segment], cs
  3349                                  %endif
  3350                                  	mov word [bp + ?placeholder], %$$othername %+ _retf_from_dual
  3351                                  	pop bx
  3352                                  	lleave
  3353                                  	retf
  3354                                  
  3355                                  %$currentname %+ _retf_from_dual:
  3356                                  	dualreturn
  3357                                  	retf
  3358                                  %endif
  3359                                  
  3360                                  
  3361                                  %assign %$counter %$counter + 1
  3362                                  %endrep
  3363                                  %pop
  3364                                  %endif
  3365                                  
  3366                                  
  3367                                  	usesection lDEBUG_CODE
  3367          ------------------       note: usesection lDEBUG_CODE
  3368                                  
  3369                                  %if _SYMBOLIC
  3370                                   %ifn _LINK || _LINK_COMPAT
  3371                                  %include "symbols.asm"
  3372                                   %endif
  3373                                  %else
  3374                                  
  3375                                  %if _PM
  3376                                  
  3377                                  
  3378                                  	hiddenusesection SECTION_OF_ %+ selector_to_segment
  3379                                  
  3380                                  	; For branches other than symbolic, here's selector_to_segment
  3381                                  	;  (as used by the puts in lineio.asm). Picked from symsnip
  3382                                  	;  binsrch.asm at revision 9c232415d568.
  3383                                  		; INP:	word [ss:sp] = selector to access
  3384                                  		; OUT:	word [ss:sp] = segment value to use for access
  3385                                  		; CHG:	-
  3386                                  dualfunction
  3387                                  selector_to_segment: section_of_function
  3388                                  	lframe dualdistance
  3389                                  	lpar word,	in_selector_out_segment
  3390                                  	lpar_return
  3391                                  	lenter
  3392                                  
  3393                                  	call _CURRENT_SECTION %+ _ispm
  3394                                  				; is it PM ?
  3395                                  	jnz .ret		; no, 86M --> (selector == segment)
  3396                                  
  3397                                  subcpu 286
  3398                                  	push ax
  3399                                  	push bx
  3400                                  	push cx
  3401                                  	push dx
  3402                                  
  3403                                  	mov bx, word [bp + ?in_selector_out_segment]
  3404                                  	mov ax, 6
  3405                                  	int 31h			; get segment base to cx:dx
  3406                                  	shr dx, 4
  3407                                  	shl cx, 12
  3408                                  	or dx, cx
  3409                                  	mov word [bp + ?in_selector_out_segment], dx
  3410                                  
  3411                                  	pop dx
  3412                                  	pop cx
  3413                                  	pop bx
  3414                                  	pop ax
  3415                                  subcpureset
  3416                                  
  3417                                  .ret:
  3418                                  	lleave
  3419                                  	dualreturn
  3420                                  	lret
  3421                                  %endif
  3422                                  
  3423                                  %endif
  3424                                  
  3425                                  
  3426                                  	; support functions for symbols.asm
  3427                                  	usesection lDEBUG_CODE
  3427          ------------------       note: usesection lDEBUG_CODE
  3428                                  %if _PM
  3429                                  dualfunction
  3430                                  push_cxdx_or_edx: section_of_function
  3431                                  	lframe dualdistance
  3432                                  	lpar dword, return
  3433                                  	lpar_return
  3434                                  	lenter
  3435                                  _no386	push cx
  3436                                  	_386_o32
  3437                                  	push dx
  3438                                  	pop word [bp + ?return]
  3439                                  	pop word [bp + ?return + 2]
  3440                                  	lleave
  3441                                  	dualreturn
  3442                                  	lret
  3443                                  %endif
  3444                                  
  3445                                  		; INP:	ds:dx -> message
  3446                                  		;	cx = length
  3447                                  		; CHG:	-
  3448                                  		; STT:	ds, es don't care
  3449                                  disp_message_length_cx: section_of_function
  3450 0000079F 50                      	push ax
  3451 000007A0 53                      	push bx
  3452 000007A1 51                      	push cx
  3453 000007A2 52                      	push dx
  3454 000007A3 06                      	push es
  3455 000007A4 1E                      	push ds
  3456 000007A5 1E                      	 push ds
  3457 000007A6 07                      	 pop es			; es:dx -> message, cx = length
  3458 000007A7 16                      	 push ss
  3459 000007A8 1F                      	 pop ds			; ds = ss (required for puts)
  3460 000007A9 E8(0000)                	call puts
  3461 000007AC 1F                      	pop ds
  3462 000007AD 07                      	pop es
  3463 000007AE 5A                      	pop dx
  3464 000007AF 59                      	pop cx
  3465 000007B0 5B                      	pop bx
  3466 000007B1 58                      	pop ax
  3467 000007B2 C3                      	retn
  3468                                  
  3469                                  		; INP:	ds:dx -> message, ASCIZ
  3470                                  		; CHG:	-
  3471                                  		; STT:	ds, es don't care
  3472                                  disp_message: section_of_function
  3473 000007B3 06                      	push es
  3474 000007B4 1E                      	 push ds
  3475 000007B5 07                      	 pop es			; es:dx -> message
  3476 000007B6 E8(0000)                	call putsz		; (sets up ds = ss internally)
  3477 000007B9 07                      	pop es
  3478 000007BA C3                      	retn
  3479                                  
  3480                                  		; INP:	al = character to display
  3481                                  		; CHG:	-
  3482                                  		; STT:	ds, es don't care
  3483                                  %ifn _LINK
  3484                                  disp_al: equ putc
  3485                                  %endif
  3486                                  
  3487                                  
  3488                                  		; Display number in ax hexadecimal, always 4 digits
  3489                                  		;
  3490                                  		; INP:	ax = number
  3491                                  		; OUT:	displayed using disp_al
  3492                                  		; CHG:	none
  3493                                  disp_ax_hex: section_of_function
  3494 000007BB 86C4                    	xchg al, ah
  3495 000007BD E80200                  	nearcall disp_al_hex
  3496 000007C0 86C4                    	xchg al, ah
  3497                                  disp_al_hex: section_of_function
  3498 000007C2 51                      	push cx
  3499 000007C3 B104                    	mov cl, 4
  3500 000007C5 D2C0                    	rol al, cl
  3501 000007C7 E80300                  	nearcall disp_al_nybble_hex
  3502 000007CA D2C0                    	rol al, cl
  3503 000007CC 59                      	pop cx
  3504                                  disp_al_nybble_hex: section_of_function
  3505 000007CD 50                      	push ax
  3506 000007CE 240F                    	and al, 0Fh
  3507 000007D0 0430                    	add al, '0'
  3508 000007D2 3C39                    	cmp al, '9'
  3509 000007D4 7602                    	jbe @F
  3510 000007D6 0407                    	add al, -'9' -1 +'A'
  3511                                  @@:
  3512 000007D8 E8(0000)                	nearcall disp_al
  3513 000007DB 58                      	pop ax
  3514 000007DC C3                      	retn
  3515                                  
  3516                                  
  3517                                  		; Display number in ax decimal
  3518                                  		;
  3519                                  		; INP:	ax = number
  3520                                  		; OUT:	displayed using disp_al
  3521                                  		; CHG:	none
  3522                                  disp_ax_dec: section_of_function			; ax (no leading zeros)
  3523 000007DD 53                      		push bx
  3524 000007DE 31DB                    		xor bx, bx
  3525                                  .pushax:
  3526 000007E0 52                      		push dx
  3527 000007E1 50                      		push ax
  3528 000007E2 08DB                    		or bl, bl
  3529 000007E4 7405                    		jz .nobl
  3530 000007E6 80EB05                  		sub bl, 5
  3531 000007E9 F6DB                    		neg bl
  3532                                  .nobl:
  3533 000007EB 51                      		push cx
  3534 000007EC B91027                  		mov cx, 10000
  3535 000007EF E81B00                  		call .divide_out
  3536 000007F2 B9E803                  		mov cx, 1000
  3537 000007F5 E81500                  		call .divide_out
  3538 000007F8 B96400                  		mov cx, 100
  3539 000007FB E80F00                  		call .divide_out
  3540 000007FE B10A                    		mov cl, 10
  3541 00000800 E80A00                  		call .divide_out
  3542                                  							; (Divisor 1 is useless)
  3543 00000803 0430                    		add al, '0'
  3544 00000805 E8(0000)                		nearcall disp_al
  3545 00000808 59                      		pop cx
  3546 00000809 58                      		pop ax
  3547 0000080A 5A                      		pop dx
  3548 0000080B 5B                      		pop bx					; Caller's register
  3549 0000080C C3                      		retn
  3550                                  
  3551                                  
  3552                                  		; INP:	ax = number
  3553                                  		;	cx = divisor
  3554                                  		; OUT:	ax = remainder of operation
  3555                                  		;	result displayed
  3556                                  .divide_out:
  3557 0000080D 52                      		push dx
  3558 0000080E 31D2                    		xor dx, dx
  3559 00000810 F7F1                    		div cx				; 0:ax / cx
  3560 00000812 52                      		push dx				; remainder
  3561 00000813 FECB                    		dec bl
  3562 00000815 7503                    		jnz .nobl2
  3563 00000817 80CF01                  		or bh, 1
  3564                                  .nobl2:
  3565 0000081A 08C7                    		or bh, al
  3566 0000081C 7405                    		jz .leadingzero
  3567 0000081E 0430                    		add al, '0'
  3568 00000820 E8(0000)                		nearcall disp_al			; display result
  3569                                   .leadingzero:
  3570 00000823 58                      		pop ax				; remainder
  3571 00000824 5A                      		pop dx
  3572 00000825 C3                      		retn
  3573                                  
  3574                                  
  3575                                   %ifn _LINK || _LINK_COMPAT
  3576                                  %if !_LOADER
  3577                                  %include "cc.asm"
  3578                                  %endif
  3579                                  
  3580                                  
  3581                                  %include "bb.asm"
  3582                                  
  3583                                  
  3584                                  %include "ee.asm"
  3585                                  
  3586                                  
  3587                                  %include "ff.asm"
  3588                                  
  3589                                  
  3590                                  %include "hh.asm"
  3591                                  
  3592                                  
  3593                                  %include "iioo.asm"
  3594                                   %endif
  3595                                  
  3596                                  
  3597                                  	usesection lDEBUG_CODE
  3597          ------------------       note: usesection lDEBUG_CODE
  3598                                  
  3599                                  %if _PM == 0 && _ELDLINKINFO
  3600                                  ispm: section_of_function
  3601 00000826 85E4                    	test sp, sp			; NZ, NC
  3602 00000828 C3                      	retn
  3603                                  
  3604                                  test_d_b_bit: section_of_function
  3605                                  test_high_limit: section_of_function
  3606 00000829 38C0                    	cmp al, al			; ZR, NC
  3607 0000082B C3                      	retn
  3608                                  
  3609                                  setes2dx: section_of_function
  3610 0000082C 8EC2                    	mov es, dx
  3611 0000082E C3                      	retn
  3612                                  
  3613                                  call_int2D: section_of_function
  3614 0000082F CD2D                    	int 2Dh
  3615 00000831 C3                      	retn
  3616                                  
  3617                                  _doscall: section_of_function
  3618                                  doscall_extseg: section_of_function
  3619 00000832 CD21                    	int 21h
  3620 00000834 C3                      	retn
  3621                                  
  3622                                  	usesection lDEBUG_DATA_ENTRY
  3622          ------------------       note: usesection lDEBUG_DATA_ENTRY
  3623 000013F4 00                      dpmi32:		db 0
  3624                                  
  3625                                  	usesection lDEBUG_CODE
  3625          ------------------       note: usesection lDEBUG_CODE
  3626                                  %endif
  3627                                  
  3628                                  %if _PM
  3629                                  
  3630                                  %if _DUALCODE
  3631                                   %assign REPEAT 2
  3632                                  %else
  3633                                   %assign REPEAT 1
  3634                                  %endif
  3635                                  
  3636                                  	usesection lDEBUG_CODE
  3637                                  %rep REPEAT
  3638                                  		; OUT:	NC
  3639                                  		;	ZR if in protected mode
  3640                                  		;	NZ otherwise
  3641                                  		; STT:	-
  3642                                  		;	([internalflags] & nodosloaded, [internalflags] & protectedmode set up)
  3643                                  _CURRENT_SECTION %+ _ispm:
  3644                                  	push ax
  3645                                  %if protectedmode & ~0FF00h
  3646                                   %error Internal flags re-ordered, adjust code here
  3647                                  %endif
  3648                                  	mov al, byte [ss:internalflags+1]	; get flag byte
  3649                                  	and al, protectedmode>>8		; separate PM flag
  3650                                  	xor al, protectedmode>>8		; ZR if in PM (NC)
  3651                                  	pop ax
  3652                                  	retn
  3653                                  
  3654                                  	usesection lDEBUG_CODE2
  3655                                  %endrep
  3656                                  	usesection lDEBUG_CODE
  3657                                  ispm equ _CURRENT_SECTION %+ _ispm
  3658                                  check_section_of ispm
  3659                                  
  3660                                  %endif
  3661                                  
  3662                                  
  3663                                  setpspdbg:
  3664                                  %if _PM
  3665                                  	mov bx, word [pspdbg]
  3666                                  %else
  3667 00000835 8CD3                    	mov bx, ss		; = word [pspdbg] (if _PM=0 or in 86M)
  3668                                  %endif
  3669                                  
  3670                                  setpsp:
  3671                                  %if _APPLICATION || _DEVICE
  3672                                  %if _BOOTLDR
  3673 00000837 F606[D901]40            	testopt [internalflags], nodosloaded
  3674 0000083C 7561                    	jnz .ret		; no PSPs -->
  3675                                  %endif
  3676                                  
  3677                                  %if _USESDA
  3678 0000083E 833E[760C]FF            	cmp word [pSDA+0], byte -1
  3679 00000843 7411                    	je .int21
  3680                                  
  3681                                  .86m:
  3682 00000845 1E                      	push ds
  3683 00000846 56                      	push si
  3684 00000847 BE[780C]                	mov si, pSDA + so16aSegSel
  3685 0000084A E80A0B                  	call update_dosdata_segment
  3686 0000084D C574FE                  	lds si, [si - so16aSegSel]
  3687 00000850 895C10                  	mov word [si+10h], bx	; set PSP segment
  3688 00000853 5E                      	pop si
  3689 00000854 1F                      	pop ds
  3690 00000855 C3                      	retn
  3691                                  
  3692                                  .int21:
  3693                                  %endif
  3694 00000856 B450                    	mov ah, 50h
  3695                                   %if _PM
  3696                                  	call ispm
  3697                                  	jnz .int21_86m
  3698                                    %if _NOEXTENDER
  3699                                  	jmp _doscall.pm		; insure non-extended (set to bx = PSP segment)
  3700                                    %else
  3701                                  	mov ax, 0002h
  3702                                  	int 31h			; segment to selector
  3703                                  	xchg bx, ax		; bx = selector
  3704                                  	mov ah, 50h		; reset to function number
  3705                                    %endif
  3706                                  .int21_86m:
  3707                                   %endif
  3708 00000858 EB39                    	jmp _int21
  3709                                  %else
  3710                                  	retn
  3711                                  %endif
  3712                                  
  3713                                  
  3714                                  getpsp:
  3715                                  %if _APPLICATION || _DEVICE
  3716                                  %if _BOOTLDR
  3717 0000085A 31DB                    	xor bx, bx		; = placeholder value if no PSPs
  3718 0000085C F606[D901]40            	testopt [internalflags], nodosloaded
  3719 00000861 753C                    	jnz .ret		; no PSPs -->
  3720                                  %endif
  3721                                  %if _USESDA
  3722 00000863 833E[760C]FF            	cmp word [pSDA+0], byte -1
  3723 00000868 7411                    	je .int21
  3724 0000086A 1E                      	push ds
  3725 0000086B 56                      	push si
  3726 0000086C BE[780C]                	mov si, pSDA + so16aSegSel
  3727 0000086F E8E50A                  	call update_dosdata_segment
  3728 00000872 C574FE                  	lds si, [si - so16aSegSel]
  3729 00000875 8B5C10                  	mov bx, word [si + 10h]	; bx = PSP segment
  3730 00000878 5E                      	pop si
  3731 00000879 1F                      	pop ds
  3732 0000087A C3                      	retn
  3733                                  
  3734                                  .int21:
  3735                                  %endif
  3736 0000087B B451                    	mov ah, 51h
  3737                                   %if _PM
  3738                                  	call ispm
  3739                                  	jnz .int21_86m
  3740                                    %if _NOEXTENDER
  3741                                  	jmp _doscall.pm		; insure non-extended (bx = PSP segment)
  3742                                    %else
  3743                                  	call _int21		; get PSP as a selector
  3744                                  	push bx
  3745                                  	dualcall selector_to_segment
  3746                                  	pop bx			; bx = PSP segment
  3747                                  	retn
  3748                                    %endif
  3749                                  .int21_86m:
  3750                                   %endif
  3751 0000087D EB14                    	jmp _int21		; in 86 Mode call DOS the normal way
  3752                                  %else
  3753                                  	xor bx, bx		; = placeholder value if no PSPs
  3754                                  	retn
  3755                                  %endif
  3756                                  
  3757                                  
  3758                                  dual2function
  3759                                  _doscall_return_es: section_of_function
  3760                                  _doscall_return_es_parameter_es_ds: section_of_function
  3761                                  	lframe dual2distance
  3762                                  	lpar word, es_ds_value
  3763                                  	lpar_return
  3764                                  %if _PM
  3765                                  	lvar word, int_number
  3766                                  	lenter
  3767                                  	mov word [bp + ?int_number], 21h
  3768                                  	push di
  3769                                  	mov di, word [ss:pm_2_86m_0]
  3770                                  	jmp near word [ss:.table + di]
  3771                                  
  3772                                  	usesection lDEBUG_DATA_ENTRY
  3773                                  		; REM:	Dispatch table in section lDEBUG_CODE
  3774                                  	align 2, db 0
  3775                                  .table:
  3776                                  	dw .86m
  3777                                  	dw .pm
  3778                                  
  3779                                  	usesection lDEBUG_CODE
  3780                                  .pm:
  3781                                  	pop di
  3782                                  	push word [bp + ?es_ds_value]
  3783                                  	push word [bp + ?es_ds_value]
  3784                                  	push word [bp + ?int_number]
  3785                                  	push word [bp + ?frame_bp]
  3786                                  	call intcall_return_parameter_es_parameter_ds
  3787                                  	pop word [bp + ?es_ds_value]		; discard returned ds
  3788                                  	pop word [bp + ?es_ds_value]		; get es
  3789                                  	jmp .ret
  3790                                  .86m:
  3791                                  	pop di
  3792                                  %else
  3793 0000087F 5589E5                  	lenter
  3794                                  %endif
  3795 00000882 06                      	 push es
  3796 00000883 1E                      	 push ds
  3797 00000884 8E5E04                  	mov ds, word [bp + ?es_ds_value]
  3798 00000887 8E4604                  	mov es, word [bp + ?es_ds_value]
  3799 0000088A CD21                    	int 21h
  3800 0000088C 8C4604                  	mov word [bp + ?es_ds_value], es
  3801 0000088F 1F                      	 pop ds
  3802 00000890 07                      	 pop es
  3803                                  .ret:
  3804 00000891 5D                      	lleave
  3805                                  	dual2return
  3806 00000892 C3                      	lret
  3807                                  
  3808                                  
  3809                                  		; Execute real Int21 instruction. If this is in PM it might get extended.
  3810                                  _int21:
  3811                                  %if _APPLICATION || _DEVICE
  3812                                  %if _BOOTLDR
  3813 00000893 9C                      	pushf
  3814 00000894 36F606[D901]40          	testopt [ss:internalflags], nodosloaded
  3815 0000089A 7504                    	jnz .reterr		; no Int21 --> (throw?)
  3816 0000089C 9D                      	popf
  3817                                  %endif
  3818 0000089D CD21                    	int 21h
  3819                                  setpsp.ret: equ $
  3820                                  getpsp.ret: equ $
  3821 0000089F C3                      	retn
  3822                                  %if _BOOTLDR
  3823                                  .reterr:
  3824 000008A0 9D                      	popf
  3825 000008A1 B80100                  	mov ax, 1
  3826 000008A4 F9                      	stc
  3827 000008A5 C3                      	retn
  3828                                  %endif
  3829                                  %else
  3830                                  	mov ax, 1
  3831                                  	stc
  3832                                  	retn
  3833                                  %endif
  3834                                  
  3835                                  
  3836                                  %if _PM
  3837                                  intcall_return_parameter_es_parameter_ds:
  3838                                  	lframe near
  3839                                  	lpar word, es_value
  3840                                  	lpar word, ds_value
  3841                                  	lpar_return
  3842                                  	lpar word, int_number
  3843                                  	lpar word, bp_value
  3844                                  	lvar 32h, 86m_call_struc
  3845                                  	lenter
  3846                                  	push es
  3847                                  	mov word [bp + ?86m_call_struc +00h], di	; edi
  3848                                  	mov word [bp + ?86m_call_struc +04h], si	; esi
  3849                                  	mov word [bp + ?86m_call_struc +10h], bx	; ebx
  3850                                  	mov word [bp + ?86m_call_struc +14h], dx	; edx
  3851                                  	mov word [bp + ?86m_call_struc +18h], cx	; ecx
  3852                                  	mov word [bp + ?86m_call_struc +1Ch], ax	; eax
  3853                                  	mov ax, word [bp + ?bp_value]
  3854                                  	mov word [bp + ?86m_call_struc +08h], ax	; bp
  3855                                  	mov al, 0					; (preserve flags!)
  3856                                  	lahf
  3857                                  	xchg al, ah
  3858                                  	mov word [bp + ?86m_call_struc +20h], ax	; flags
  3859                                  	xor ax, ax
  3860                                  	mov word [bp + ?86m_call_struc +0Ch + 2], ax
  3861                                  	mov word [bp + ?86m_call_struc +0Ch], ax
  3862                                  	mov word [bp + ?86m_call_struc +2Eh], ax	; sp
  3863                                  	mov word [bp + ?86m_call_struc +30h], ax	; ss
  3864                                  	mov ax, word [bp + ?es_value]			; usually [pspdbg]
  3865                                  	mov word [bp + ?86m_call_struc +22h], ax	; es
  3866                                  	mov ax, word [bp + ?ds_value]			; usually [pspdbg]
  3867                                  	mov word [bp + ?86m_call_struc +24h], ax	; ds
  3868                                  	push ss
  3869                                  	pop es				; => stack
  3870                                  	lea di, [bp + ?86m_call_struc]	; -> 86-Mode call structure
  3871                                  _386	movzx edi, di			; (previously checked b[dpmi32] here)
  3872                                  	mov bx, word [bp + ?int_number]			; int#
  3873                                  	xor cx, cx
  3874                                  	mov ax, 0300h
  3875                                  	int 31h
  3876                                  	mov ah, byte [bp + ?86m_call_struc +20h]	; flags
  3877                                  	sahf
  3878                                  	mov di, word [bp + ?86m_call_struc +00h]	; edi
  3879                                  	mov si, word [bp + ?86m_call_struc +04h]	; esi
  3880                                  	mov bx, word [bp + ?86m_call_struc +10h]	; ebx
  3881                                  	mov dx, word [bp + ?86m_call_struc +14h]	; edx
  3882                                  	mov cx, word [bp + ?86m_call_struc +18h]	; ecx
  3883                                  	mov ax, word [bp + ?86m_call_struc +1Ch]	; eax
  3884                                  	push word [bp + ?86m_call_struc +22h]		; return es value
  3885                                  	pop word [bp + ?es_value]			;  in the parameter
  3886                                  	push word [bp + ?86m_call_struc +24h]		; return ds value
  3887                                  	pop word [bp + ?ds_value]			;  in the parameter
  3888                                  	pop es
  3889                                  	lleave
  3890                                  	lret
  3891                                  
  3892                                  intcall:
  3893                                  	lframe near
  3894                                  	lpar word, es_ds_value
  3895                                  	lpar word, int_number
  3896                                  	lenter
  3897                                  	push word [bp + ?es_ds_value]			; es
  3898                                  	push word [bp + ?es_ds_value]			; ds
  3899                                  	push word [bp + ?int_number]			; int number
  3900                                  	push word [bp + ?frame_bp]			; bp
  3901                                  	call intcall_return_parameter_es_parameter_ds
  3902                                  		; (discard returned parameters ?es_value, ?ds_value, done by lleave)
  3903                                  	lleave , forcerestoresp
  3904                                  	lret
  3905                                  
  3906                                  
  3907                                  %if _EXTENSIONS
  3908                                  intcall_ext_return_es: section_of_function
  3909                                  	lframe 6
  3910                                  	lpar word, es_ds_value
  3911                                  	lpar word, int_number
  3912                                  	lpar_return
  3913                                  	lenter
  3914                                  	push word [bp + ?es_ds_value]			; es
  3915                                  	push word [bp + ?es_ds_value]			; ds
  3916                                  	push word [bp + ?int_number]			; int number
  3917                                  	push word [bp + ?frame_bp]			; bp
  3918                                  	call intcall_return_parameter_es_parameter_ds
  3919                                  	pop word [bp + ?es_ds_value]			; discard ds
  3920                                  	pop word [bp + ?es_ds_value]			; return es
  3921                                  	lleave , optimiserestoresp
  3922                                  	retn
  3923                                  
  3924                                  
  3925                                  doscall_extseg: section_of_function
  3926                                  	pushf
  3927                                  	call ispm
  3928                                  	jnz .rm
  3929                                  subcpu 286
  3930                                  	popf
  3931                                  .pm:
  3932                                  	push word [ss:extseg]
  3933                                  	push 21h
  3934                                  	call intcall
  3935                                  	retn
  3936                                  subcpureset
  3937                                  .rm:
  3938                                  	popf
  3939                                  	jmp _int21
  3940                                  %endif
  3941                                  
  3942                                  call_int2D: section_of_function
  3943                                  	call ispm
  3944                                  	jnz short .rm
  3945                                  subcpu 286
  3946                                  	push word [ss:pspdbg]	; es ds value. generally unused
  3947                                  	push 2Dh		; interrupt 2Dh
  3948                                  	call intcall		; call it
  3949                                  	retn
  3950                                  subcpureset
  3951                                  .rm:
  3952                                  	int 2Dh			; directly call int 2Dh
  3953                                  	retn
  3954                                  
  3955                                  
  3956                                  		; Called in PM only, ds unknown.
  3957                                  		;
  3958                                  		; INP:	-
  3959                                  		; OUT:	CY if no DOS extender available ("MS-DOS" on Int2F.168A)
  3960                                  		;	NC if DOS extender available
  3961                                  		; CHG:	-
  3962                                  isextenderavailable:
  3963                                  subcpu 286
  3964                                  	push ds
  3965                                  	push es
  3966                                  	pusha
  3967                                  	push ss
  3968                                  	pop ds
  3969                                  	mov si, msg.msdos
  3970                                  _386	movzx esi, si
  3971                                  	mov ax, 168Ah
  3972                                  	int 2Fh
  3973                                  	cmp al, 1			; CY if al is zero
  3974                                  	cmc				; NC if al is zero, CY else
  3975                                  	popa
  3976                                  	pop es
  3977                                  	pop ds
  3978                                  	retn
  3979                                  subcpureset
  3980                                  
  3981                                  nodosextinst:
  3982                                  	push ss
  3983                                  	pop ds
  3984                                  	mov ax, 013Dh
  3985                                  	call setrc
  3986                                  	mov dx, nodosext
  3987                                  	jmp putsz
  3988                                  %endif
  3989                                  
  3990                                  
  3991                                   %ifn _LINK || _LINK_COMPAT
  3992                                  %if !_LOADER
  3993                                  %include "ll.asm"
  3994                                  %endif
  3995                                  
  3996                                  
  3997                                  %include "mm.asm"
  3998                                   %endif
  3999                                  
  4000                                  
  4001                                  	usesection lDEBUG_CODE
  4001          ------------------       note: usesection lDEBUG_CODE
  4002                                  
  4003                                  %if !_LOADER
  4004                                  		; K command - enter Kommand line in new style
  4005                                  		; N command - change the Name of the program being debugged
  4006                                  		;
  4007                                  		; N command is subject to weird Microsoft compatibility if
  4008                                  		;  an options2 flag is set. In this mode, the entire line_in
  4009                                  		;  contents after the N command are used for the command line
  4010                                  		;  tail rather than only the tail after the program name.
  4011                                  		;  (Yes, really.) Also, the debuggee ds is assumed to point
  4012                                  		;  to a PSP and the FCBs and command line tail are written
  4013                                  		;  to this segment.
  4014                                  %if _MS_N_COMPAT
  4015                                  nn:
  4016 000008A6 800E[DF01]80            	setopt [internalflags2], dif2_nn_capitalise
  4017                                  				; prepare old style (MS Debug compatibility)
  4018 000008AB F606[A601]02            	testopt [options2], opt2_nn_capitalise
  4019 000008B0 7505                    	jnz @F			; leave it set -->
  4020 000008B2 8026[DF01]7F            	clropt [internalflags2], dif2_nn_capitalise
  4021                                  				; disable old style, use new style
  4022                                  @@:
  4023                                  
  4024 000008B7 800E[DF01]40            	setopt [internalflags2], dif2_nn_compat
  4025                                  				; prepare old style (MS Debug compatibility)
  4026 000008BC F606[A601]01            	testopt [options2], opt2_nn_compat
  4027 000008C1 750C                    	jnz @FF			; leave it set -->
  4028 000008C3 EB05                    	jmp @F
  4029                                  kk:
  4030 000008C5 8026[DF01]7F            	clropt [internalflags2], dif2_nn_capitalise
  4031                                  				; also disable capitalisation
  4032                                  @@:
  4033 000008CA 8026[DF01]BF            	clropt [internalflags2], dif2_nn_compat
  4034                                  				; disable old style, use new style
  4035                                  @@:
  4036                                  %else
  4037                                  kk:
  4038                                  nn:
  4039                                  %endif
  4040 000008CF 16                      	push ss
  4041 000008D0 07                      	pop es
  4042                                  
  4043                                  %if _MS_N_COMPAT
  4044 000008D1 4E                      	dec si			; -> first non-blank
  4045                                  @@:
  4046 000008D2 4E                      	dec si			; -> before prior start of command
  4047 000008D3 803C20                  	cmp byte [si], 32	; blank ?
  4048 000008D6 74FA                    	je @B
  4049 000008D8 803C09                  	cmp byte [si], 9
  4050 000008DB 74F5                    	je @B			; yes, decrement -->
  4051 000008DD 803C2C                  	cmp byte [si], ','
  4052 000008E0 74F0                    	je @B
  4053 000008E2 46                      	inc si			; restore -> start of command (first blank, if any)
  4054 000008E3 AC                      	lodsb			; make al = first text byte, si -> after
  4055                                  %endif
  4056                                  
  4057                                  %if _BOOTLDR
  4058                                   %if _APPLICATION || _DEVICE
  4059 000008E4 36F606[D901]40          	testopt [ss:internalflags], nodosloaded
  4060 000008EA 740C                    	jz @F
  4061                                   %endif
  4062 000008EC BA[0000]                	mov dx, msg.nobootsupp
  4063 000008EF B81901                  	mov ax, 0119h
  4064 000008F2 E83309                  	call setrc
  4065 000008F5 E9(0000)                	jmp putsz
  4066                                  @@:
  4067                                  %endif
  4068                                  %if _APPLICATION || _DEVICE
  4069                                   %if _MS_N_COMPAT
  4070 000008F8 F606[DF01]40            	testopt [internalflags2], dif2_nn_compat
  4071 000008FD 7405                    	jz @F
  4072 000008FF E89800                  	call nn_copy_to_line_out
  4073 00000902 4E                      	dec si
  4074 00000903 AC                      	lodsb			; restore al
  4075                                  @@:
  4076                                   %endif
  4077 00000904 BF8000                  	mov	di, DTA		; destination address
  4078                                  %if _MS_N_COMPAT	; (not needed if not including the blank scan)
  4079 00000907 E8(0000)                	call skipcomm0		; skip blanks before program load filename
  4080                                  %endif
  4081                                  
  4082                                  		; Copy and canonicalize file name.
  4083                                  nn1:
  4084 0000090A 81FF[6E01]              	cmp di, N_BUFFER_END
  4085 0000090E 7313                    	jae .toolong
  4086 00000910 E88B01                  	call ifsep		; check for separators CR, blank, tab, comma, ;, =
  4087 00000913 742E                    	je nn3			; if end of file name
  4088 00000915 363A06[A30C]            	cmp al, byte [ss:swch1]
  4089                                  		; The use of ss here appears to be intended to
  4090                                  		;  allow loading from ds different from the
  4091                                  		;  data entry and PSP segment, However, the
  4092                                  		;  subsequent copy of the command tail around
  4093                                  		;  nn4 does not participate in this scheme.
  4094                                  		; So if this is used make sure to adjust that.
  4095 0000091A 7427                    	je nn3			; if '/' (and '/' is the switch character)
  4096 0000091C E8(0000)                	call capitalise
  4097 0000091F AA                      	stosb
  4098 00000920 AC                      	lodsb
  4099 00000921 EBE7                    	jmp short nn1		; back for more
  4100                                  
  4101                                  .toolong:
  4102                                  nn4.toolong:
  4103 00000923 16                      	push ss
  4104 00000924 1F                      	pop ds
  4105 00000925 BA[0000]                	mov dx, msg.n_toolongname
  4106 00000928 E8(0000)                	call putsz
  4107 0000092B B82601                  	mov ax, 0126h
  4108 0000092E E8F708                  	call setrc
  4109 00000931 BF[6B01]                	mov di, N_BUFFER_END - 3
  4110 00000934 B000                    	mov al, 0		; truncate the name
  4111 00000936 AA                      	stosb
  4112 00000937 A2[580D]                	mov byte [fileext], al	; invalid / none
  4113 0000093A 893E[E20D]              	mov word [execblk.cmdline], di
  4114 0000093E B8000D                  	mov ax, 13 << 8		; 0 in low byte (tail length), CR in high byte
  4115 00000941 AB                      	stosw
  4116 00000942 C3                      	retn
  4117                                  
  4118                                  
  4119                                  nn3:
  4120 00000943 16                      	push ss
  4121 00000944 1F                      	pop ds
  4122 00000945 B000                    	mov al, 0		; null terminate the file name string
  4123 00000947 AA                      	stosb
  4124 00000948 893E[E20D]              	mov word [execblk.cmdline], di
  4125                                  				; save start of command tail
  4126                                  
  4127                                  %if _DEBUG4
  4128                                  	push dx
  4129                                  	mov dx, DTA
  4130                                  	call d4disp_msg
  4131                                  	mov dx, crlf
  4132                                  	call d4disp_msg
  4133                                  	pop dx
  4134                                  %endif
  4135                                  		; Determine file extension
  4136 0000094C 81FF8100                	cmp di, DTA+1
  4137 00000950 7438                    	je nn3d			; if no file name at all
  4138 00000952 81FF8500                	cmp di, DTA+5
  4139 00000956 7230                    	jb nn3c			; if no extension (name too short)
  4140 00000958 B008                    	mov al, EXT_HEX
  4141 0000095A 817DFB2E48              	cmp word [di-5], ".H"
  4142 0000095F 7507                    	jne nn3a		; if not .HEX
  4143 00000961 817DFD4558              	cmp word [di-3], "EX"
  4144 00000966 7422                    	je nn3d			; if .HEX
  4145                                  nn3a:
  4146 00000968 B004                    	mov al, EXT_EXE
  4147 0000096A 817DFB2E45              	cmp word [di-5], ".E"
  4148 0000096F 7507                    	jne nn3b		; if not .EXE
  4149 00000971 817DFD5845              	cmp word [di-3], "XE"
  4150 00000976 7412                    	je nn3d			; if .EXE
  4151                                  nn3b:
  4152 00000978 B002                    	mov al, EXT_COM
  4153 0000097A 817DFB2E43              	cmp word [di-5], ".C"
  4154 0000097F 7507                    	jne nn3c		; if not .COM
  4155 00000981 817DFD4F4D              	cmp word [di-3], "OM"
  4156 00000986 7402                    	je nn3d			; if .COM
  4157                                  nn3c:
  4158 00000988 B001                    	mov al, EXT_OTHER
  4159                                  nn3d:
  4160 0000098A A2[580D]                	mov byte [fileext], al
  4161                                  
  4162                                  		; Finish the N command
  4163 0000098D 57                      	push di
  4164                                  %if _MS_N_COMPAT
  4165 0000098E F606[DF01]40            	testopt [internalflags2], dif2_nn_compat
  4166 00000993 751D                    	jnz @F
  4167 00000995 E80200                  	call nn_copy_to_line_out
  4168 00000998 EB18                    	jmp @F
  4169                                  
  4170                                  		; INP:	si - 1 -> command line tail
  4171                                  		; OUT:	line_out has tail, terminated by 0 or 13 (CR)
  4172                                  		; CHG:	di, al
  4173                                  nn_copy_to_line_out:
  4174 0000099A 56                      	push si
  4175                                  %endif
  4176 0000099B BF[CE0A]                	mov di, line_out
  4177 0000099E 4E                      	dec si
  4178                                  nn4:
  4179 0000099F AC                      	lodsb			; copy the remainder to line_out
  4180 000009A0 F606[DF01]80            	testopt [internalflags2], dif2_nn_capitalise
  4181 000009A5 7403                    	jz .nocaps
  4182 000009A7 E8(0000)                	call capitalise
  4183                                  .nocaps:
  4184 000009AA AA                      	stosb
  4185 000009AB E8(0000)                	call iseol?.notsemicolon
  4186 000009AE 75EF                    	jne nn4
  4187                                  %if _MS_N_COMPAT
  4188 000009B0 5E                      	pop si
  4189 000009B1 C3                      	retn
  4190                                  
  4191                                  @@:
  4192                                  %endif
  4193 000009B2 E88309                  	call InDOS
  4194 000009B5 740E                    	jz .fcb_setup
  4195                                  %if _DEVICE
  4196 000009B7 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4197 000009BC 7505                    	jnz @F
  4198                                  %endif
  4199 000009BE 8326[F80D]00            	and word [reg_eax], 0
  4200                                  @@:
  4201 000009C3 EB23                    	jmp .fcb_none
  4202                                  
  4203                                  .fcb_setup:
  4204                                  		; Set up FCBs.
  4205 000009C5 BE[CE0A]                	mov si, line_out
  4206 000009C8 BF5C00                  	mov di, 5Ch
  4207 000009CB E87A00                  	call nn6		; do first FCB
  4208                                  %if _DEVICE
  4209 000009CE F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4210 000009D3 7503                    	jnz @F
  4211                                  %endif
  4212 000009D5 A2[F80D]                	mov byte [reg_eax], al
  4213                                  @@:
  4214 000009D8 BF6C00                  	mov di, 6Ch
  4215 000009DB E86A00                  	call nn6		; second FCB
  4216                                  %if _DEVICE
  4217 000009DE F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4218 000009E3 7503                    	jnz @F
  4219                                  %endif
  4220 000009E5 A2[F90D]                	mov byte [reg_eax+1], al
  4221                                  @@:
  4222                                  .fcb_none:
  4223                                  
  4224                                  		; Copy command tail.
  4225 000009E8 BE[CE0A]                	mov si, line_out
  4226 000009EB 5F                      	pop di
  4227 000009EC 81FF[6C01]              	cmp di, N_BUFFER_END - 2
  4228 000009F0 7203E92EFF              	jae .toolong
  4229 000009F5 57                      	push di			; -> counter byte
  4230 000009F6 47                      	inc di			; -> first byte of buffer
  4231 000009F7 8D5D7F                  	lea bx, [di + 127]	; -> behind last byte of PSP target buffer
  4232                                  				;  (within 128 bytes the CR must be written)
  4233 000009FA B8[6E01]                	mov ax, N_BUFFER_END	; -> behind last byte in our N buffer
  4234 000009FD 39C3                    	cmp bx, ax		; use whichever limit is smaller
  4235 000009FF 7202                    	jb @F
  4236 00000A01 89C3                    	mov bx, ax		; N buffer is smaller, use it as limit
  4237                                  @@:
  4238                                  nn5:
  4239 00000A03 39DF                    	cmp di, bx		; can store one more (possibly CR) ?
  4240 00000A05 7331                    	jae .toolong		; no -->
  4241 00000A07 AC                      	lodsb
  4242 00000A08 AA                      	stosb			; store byte
  4243 00000A09 E8(0000)                	call iseol?.notsemicolon; end of string ?
  4244 00000A0C 75F5                    	jne nn5			; if not end of string -->
  4245                                  .toolong_terminate:	; jump destination from .toolong
  4246 00000A0E C645FF0D                	mov byte [di - 1], 13	; (just overwrite this unconditionally)
  4247 00000A12 57                      	push di
  4248 00000A13 89F9                    	mov cx, di
  4249 00000A15 81E9[6E01]              	sub cx, N_BUFFER_END
  4250 00000A19 F7D9                    	neg cx
  4251 00000A1B 31C0                    	xor ax, ax
  4252 00000A1D F3AA                    	rep stosb
  4253 00000A1F 5F                      	pop di
  4254 00000A20 58                      	pop ax			; recover old DI
  4255 00000A21 97                      	xchg ax, di
  4256 00000A22 29F8                    	sub ax, di		; compute length of tail
  4257                                  %if _MS_N_COMPAT
  4258 00000A24 89C1                    	mov cx, ax
  4259                                  %endif
  4260 00000A26 48                      	dec ax
  4261 00000A27 48                      	dec ax
  4262 00000A28 AA                      	stosb
  4263                                  %if _MS_N_COMPAT
  4264 00000A29 F606[DF01]40            	testopt [internalflags2], dif2_nn_compat
  4265 00000A2E 7407                    	jz @F
  4266 00000A30 8E06[180E]              	mov es, word [reg_ds]	; modify current ds, assuming a PSP
  4267 00000A34 E8(0000)                	call ll_copy_cmdline_and_fcbs.have_cx
  4268                                  @@:
  4269                                  %endif
  4270                                  %if _DEBUG4
  4271                                  	mov dx, DTA
  4272                                  	call d4disp_msg
  4273                                  	mov dx, crlf
  4274                                  	call d4disp_msg
  4275                                  %endif
  4276 00000A37 C3                      	retn			; done
  4277                                  
  4278                                  .toolong:
  4279 00000A38 BA[0000]                	mov dx, msg.n_toolongtail
  4280 00000A3B E8(0000)                	call putsz
  4281 00000A3E B82701                  	mov ax, 0127h
  4282 00000A41 E8E407                  	call setrc
  4283 00000A44 89DF                    	mov di, bx
  4284 00000A46 EBC6                    	jmp .toolong_terminate
  4285                                  
  4286                                  
  4287                                  		; Subroutine to process an FCB.
  4288                                  		;
  4289                                  		; INP:	di -> FCB
  4290                                  		;	si -> input
  4291                                  nn6:
  4292 00000A48 AC                      	lodsb
  4293 00000A49 E8(0000)                	call iseol?.notsemicolon
  4294 00000A4C 740B                    	je nn7			; if end
  4295 00000A4E E84D00                  	call ifsep
  4296 00000A51 74F5                    	je nn6			; if separator (other than CR)
  4297 00000A53 3A06[A20C]              	cmp al, byte [switchar]
  4298 00000A57 741B                    	je nn10			; if switch character
  4299                                  nn7:
  4300 00000A59 4E                      	dec si
  4301 00000A5A B80129                  	mov ax, 2901h		; parse filename
  4302                                  	doscall
  1497 00000A5D CD21                <1>  int 21h
  4303 00000A5F 50                      	push ax			; save AL
  4304                                  nn8:
  4305 00000A60 AC                      	lodsb			; skip till separator
  4306 00000A61 E83A00                  	call ifsep
  4307 00000A64 7406                    	je nn9			; if separator character (including CR)
  4308 00000A66 3A06[A30C]              	cmp al, byte [swch1]
  4309 00000A6A 75F4                    	jne nn8			; if not switchar (sort of)
  4310                                  nn9:
  4311 00000A6C 4E                      	dec si
  4312 00000A6D 58                      	pop ax			; recover AL
  4313 00000A6E 3C01                    	cmp al, 1
  4314 00000A70 7501                    	jne nn9a		; if not 1
  4315 00000A72 48                      	dec ax
  4316                                  nn9a:
  4317 00000A73 C3                      	retn
  4318                                  
  4319                                  		; Handle a switch (differently).
  4320 00000A74 AC                      nn10:	lodsb
  4321 00000A75 E8(0000)                	call iseol?.notsemicolon
  4322 00000A78 74DF                    	je nn7			; if end of string
  4323 00000A7A E82100                  	call ifsep
  4324 00000A7D 74F5                    	je nn10			; if another separator (other than CR)
  4325 00000A7F B000                    	mov al, 0
  4326 00000A81 AA                      	stosb
  4327 00000A82 4E                      	dec si
  4328 00000A83 AC                      	lodsb
  4329 00000A84 3C61                    	cmp al, 'a'
  4330 00000A86 7206                    	jb nn11			; if not a lower case letter
  4331 00000A88 3C7A                    	cmp al, 'z'
  4332 00000A8A 7702                    	ja nn11
  4333 00000A8C 24DF                    	and al, TOUPPER		; convert to upper case
  4334 00000A8E AA                      nn11:	stosb
  4335 00000A8F B82020                  	mov ax, 32<<8|32
  4336 00000A92 AB                      	stosw
  4337 00000A93 AB                      	stosw
  4338 00000A94 AB                      	stosw
  4339 00000A95 AB                      	stosw
  4340 00000A96 AB                      	stosw
  4341 00000A97 31C0                    	xor ax, ax
  4342 00000A99 AB                      	stosw
  4343 00000A9A AB                      	stosw
  4344 00000A9B AB                      	stosw
  4345 00000A9C AB                      	stosw
  4346 00000A9D C3                      	retn			; return with al = 0
  4347                                  
  4348                                  
  4349                                  		; Compare character with separators
  4350                                  		;
  4351                                  		; INP:	al = character
  4352                                  		; OUT:	ZR if al is CR, NUL, blank, tab, comma, semicolon, or equal sign
  4353                                  		;	NZ else
  4354                                  		; REM:	This is only used for parsing FCBs.
  4355                                  ifsep: section_of_function
  4356 00000A9E E8(0000)                	call iseol?		; semicolon or CR or NUL
  4357 00000AA1 740E                    	je .return
  4358 00000AA3 3C20                    	cmp al, 32
  4359 00000AA5 740A                    	je .return
  4360 00000AA7 3C09                    	cmp al, 9
  4361 00000AA9 7406                    	je .return
  4362 00000AAB 3C2C                    	cmp al, ','
  4363 00000AAD 7402                    	je .return
  4364 00000AAF 3C3D                    	cmp al, '='
  4365                                  .return:
  4366 00000AB1 C3                      	retn
  4367                                  %endif
  4368                                  %endif
  4369                                  
  4370                                  
  4371                                  %if _ELDLINKINFO && !_PM
  4372                                  verifysegm_or_error: section_of_function
  4373                                  verifysegm: section_of_function
  4374 00000AB2 F8                      	clc
  4375 00000AB3 C3                      	retn
  4376                                  %endif
  4377                                  
  4378                                  		; Ensure segment in bx is writeable
  4379                                  		;
  4380                                  		; INP:	bx = selector/segment
  4381                                  		; OUT:	NC if in 86M, bx unchanged
  4382                                  		;	NC if in PM and bx not a code segment, bx unchanged
  4383                                  		;	NC if in PM and was a code segment,
  4384                                  		;	 bx = word [scratchsel], set up to mirror INP:bx selector
  4385                                  		;	CY if in PM and a failure occurred, segment not writeable
  4386                                  		; CHG:	bx
  4387                                  		; STT:	ss = debugger data selector
  4388                                  %if _PM
  4389                                  verifysegm_or_error: section_of_function
  4390                                  	push bx
  4391                                  	call verifysegm
  4392                                  	jc .ro
  4393                                  	add sp, 2		; (discard bx on stack)
  4394                                  	retn
  4395                                  
  4396                                  .ro:
  4397                                  	push ss
  4398                                  	pop es
  4399                                  	call ee0a
  4400                                  	mov di, msg.readonly_verifysegm.selector
  4401                                  	pop ax			; get original selector
  4402                                  	call hexword
  4403                                  	mov dx, msg.readonly_verifysegm
  4404                                  	call putsz_error
  4405                                  	mov ax, 0109h
  4406                                  	call setrc
  4407                                  	jmp cmd3
  4408                                  
  4409                                  
  4410                                  verifysegm: section_of_function
  4411                                  	call ispm
  4412                                  	jnz .rm			; (NC)
  4413                                  	push ax
  4414                                  	push es
  4415                                  	_386_o32	; push edi
  4416                                  	push di
  4417                                  	push bp
  4418                                  	mov bp, sp
  4419                                  	sub sp, 8
  4420                                  	 push ss
  4421                                  	 pop es
  4422                                  	mov di, sp
  4423                                  _386	movzx edi, di
  4424                                  	mov ax, 000Bh		; get descriptor
  4425                                  	int 31h
  4426                                  	jc @F
  4427                                  	test byte [di+5], 8	; code segment ?
  4428                                  	jz @F			; (NC) no -->
  4429                                  	and byte [di+5], 0F3h	; reset CODE+conforming attr
  4430                                  	or byte [di+5], 2	; set writable
  4431                                  	mov bx, word [scratchsel]
  4432                                  	mov ax, 000Ch
  4433                                  	int 31h
  4434                                  @@:
  4435                                  	mov sp, bp
  4436                                  	pop bp
  4437                                  	_386_o32	; pop edi
  4438                                  	pop di
  4439                                  	pop es
  4440                                  	pop ax
  4441                                  .rm:
  4442                                  .retn:
  4443                                  	retn
  4444                                  
  4445                                  subcpu 286
  4446                                  		; INP:	dx = 86 Mode segment to access
  4447                                  		; OUT:	bx = scratch selector, addressing that segment,
  4448                                  		;	 limit set to 64 KiB (allow all 16-bit accesses)
  4449                                  		; CHG:	-
  4450                                  		; STT:	ss = lDEBUG_DATA_ENTRY selector, in PM
  4451                                  setrmsegm: section_of_function
  4452                                  	mov bx, word [ss:scratchsel]
  4453                                  	call setrmaddr
  4454                                  
  4455                                  		; INP:	bx = selector
  4456                                  		; OUT:	limit set to 0FFFFh
  4457                                  		; STT:	in PM
  4458                                  setrmlimit: section_of_function
  4459                                  	push ax
  4460                                  	push cx
  4461                                  	push dx
  4462                                  	xor cx, cx
  4463                                  ; _386	dec cx		; limit 0FFFF_FFFFh on 386+
  4464                                  		; We don't want that here. All users expect a 64 KiB segment.
  4465                                  	mov dx, -1	; limit 0FFFFh on 286
  4466                                  	mov ax, 8
  4467                                  	int 31h		; set limit
  4468                                  	pop dx		; restore base segment
  4469                                  	pop cx
  4470                                  	pop ax
  4471                                  	retn
  4472                                  
  4473                                  setrmaddr:		;<--- set selector in BX to segment address in DX
  4474                                  .:
  4475                                  	push ax
  4476                                  	push cx
  4477                                  	push dx
  4478                                  	mov cx, dx
  4479                                  	shl dx, 4
  4480                                  	shr cx, 12	; cx:dx = base address
  4481                                  	mov ax, 7
  4482                                  	int 31h		; set base
  4483                                  	pop dx
  4484                                  	pop cx
  4485                                  	pop ax
  4486                                  	retn
  4487                                  
  4488                                  subcpureset
  4489                                  %endif
  4490                                  
  4491                                  		; Read a byte relative to cs:eip
  4492                                  		;
  4493                                  		; INP:	reg_cs, reg_eip
  4494                                  		;	cx = (signed) eip adjustment
  4495                                  		; OUT:	al = byte at that address
  4496                                  		;	(e)bx = new offset (eip+adjustment)
  4497                                  		; CHG:	-
  4498                                  getcseipbyte:
  4499 00000AB4 06                      	push es
  4500                                  %if _PM
  4501                                  	mov bx, word [reg_cs]
  4502                                  	mov es, bx
  4503                                  	call test_d_b_bit
  4504                                  	jz .16
  4505                                  [cpu 386]
  4506                                  	mov ebx, dword [reg_eip]
  4507                                  	push edx
  4508                                  	movsx edx, cx
  4509                                  	add ebx, edx
  4510                                  ..@getcseipbyte_fault_skip_6_near_call:
  4511                                  	mov al, byte [es:ebx]
  4512                                  	pop edx
  4513                                  	pop es
  4514                                  	retn
  4515                                  __CPU__
  4516                                  .16:
  4517                                  %else
  4518 00000AB5 8E06[240E]              	mov es, word [reg_cs]
  4519                                  %endif
  4520 00000AB9 8B1E[300E]              	mov bx, word [reg_eip]
  4521 00000ABD 01CB                    	add bx, cx
  4522                                  ..@getcseipbyte_fault_skip_2_near_call:
  4523 00000ABF 268A07                  	mov al, byte [es:bx]
  4524 00000AC2 07                      	pop es
  4525 00000AC3 C3                      	retn
  4526                                  
  4527                                  		; Write to a byte relative to cs:eip
  4528                                  		;
  4529                                  		; INP:	reg_cs, reg_eip
  4530                                  		;	cx = (signed) eip adjustment
  4531                                  		;	al = source byte to write
  4532                                  		; OUT:	NC if apparently written
  4533                                  		;	CY if failed to get a writeable selector
  4534                                  		; CHG:	(e)bx
  4535                                  setcseipbyte:
  4536 00000AC4 06                      	push es
  4537                                  %if _PM
  4538                                  	mov bx, word [reg_cs]
  4539                                  	call verifysegm
  4540                                  	jc .ret
  4541                                  	mov es, bx
  4542                                  	call test_d_b_bit
  4543                                  	jz .16
  4544                                  [cpu 386]
  4545                                  	mov ebx, dword [reg_eip]
  4546                                  	push edx
  4547                                  	movsx edx, cx
  4548                                  ..@setcseipbyte_fault_skip_6_near_call:
  4549                                  	mov byte [es:ebx+edx],al
  4550                                  	pop edx
  4551                                  	pop es
  4552                                  	clc
  4553                                  	retn
  4554                                  __CPU__
  4555                                  .16:
  4556                                  %else
  4557 00000AC5 8E06[240E]              	mov es, word [reg_cs]
  4558                                  %endif
  4559 00000AC9 8B1E[300E]              	mov bx, word [reg_eip]
  4560 00000ACD 01CB                    	add bx, cx
  4561                                  ..@setcseipbyte_fault_skip_2_near_call:
  4562 00000ACF 268807                  	mov byte [es:bx], al
  4563 00000AD2 F8                      	clc
  4564                                  .ret:
  4565 00000AD3 07                      	pop es
  4566 00000AD4 C3                      	retn
  4567                                  
  4568                                  		; Exchange byte with memory
  4569                                  		;
  4570                                  		; INP:	bx:(e)dx-> destination byte
  4571                                  		;	al = source byte
  4572                                  		; REM:	Determines whether to use edx by the
  4573                                  		;	 segment limit of the selector.
  4574                                  		;	 (Uses in run.asm always pass a segmented
  4575                                  		;	 address obtained from getsegmented. This
  4576                                  		;	 will have edxh = 0 always so it doesn't
  4577                                  		;	 matter whether we use edx or dx.)
  4578                                  		; OUT:	CY if failed due to segment not writable
  4579                                  		;	NC if successful,
  4580                                  		;	 al = previous value of destination byte
  4581                                  		; CHG:	ah
  4582                                  writemem:
  4583                                  %if _DEBUG1
  4584                                  	push dx
  4585                                  	push ax
  4586                                  
  4587                                  	call getlinear_high_limit.do_not_use_test	; NB do NOT resetmode
  4588                                  	jc @F			; already an error ?  then return --> (CY)
  4589                                  	push bx
  4590                                  	push cx
  4591                                  	mov bx, test_records_Writemem
  4592                                  	call handle_test_case_multiple_16
  4593                                  				; check whether this should testcase the error
  4594                                  				; CY to indicate error from this call
  4595                                  	pop cx
  4596                                  	pop bx
  4597                                  @@:
  4598                                  	pop ax
  4599                                  	pop dx
  4600                                  	jnc .do_not_use_test
  4601                                  	retn			; return CY here
  4602                                  
  4603                                  %endif
  4604                                  .do_not_use_test:
  4605                                  
  4606 00000AD5 88C4                    	mov ah, al
  4607                                  %if _PM
  4608                                  	call ispm
  4609                                  	jnz .16			; (NC from ispm) -->
  4610                                  	call verifysegm		; make bx a writeable segment
  4611                                  	jc .ret
  4612                                  _386_PM	call test_high_limit	; 32-bit segment ?
  4613                                  	jz .16			; (NC from test_d_b_bit) -->
  4614                                  [cpu 386]
  4615                                  	push ds
  4616                                  	mov ds, bx
  4617                                  ..@writemem_fault_skip_2_near_call_a:
  4618                                  	xchg al, byte [edx]
  4619                                  ..@writemem_fault_skip_2_near_call_b:
  4620                                  	cmp ah, byte [edx]
  4621                                  	pop ds
  4622                                  __CPU__
  4623                                  	jmp short .cmp
  4624                                  .16:
  4625                                  %endif
  4626 00000AD7 1E                      	push ds
  4627 00000AD8 8EDB                    	mov ds, bx
  4628 00000ADA 53                      	push bx
  4629 00000ADB 89D3                    	mov bx, dx
  4630                                  ..@writemem_fault_skip_4_near_call_a:
  4631 00000ADD 8607                    	xchg al, byte [bx]
  4632                                  ..@writemem_fault_skip_4_near_call_b:
  4633 00000ADF 3A27                    	cmp ah, byte [bx]
  4634 00000AE1 5B                      	pop bx
  4635 00000AE2 1F                      	pop ds
  4636                                  .cmp:
  4637 00000AE3 7401                    	je .ret			; (NC)
  4638 00000AE5 F9                      	stc			; Failed to compare (i.e. memory wasn't our byte after writing).
  4639                                  				; This check catches ROM that will silently fail to write.
  4640                                  .ret:
  4641 00000AE6 C3                      	retn
  4642                                  
  4643                                  
  4644                                  		; Read byte from memory
  4645                                  		;
  4646                                  		; INP:	bx:(e)dx-> destination byte
  4647                                  		; REM:	Determines whether to use edx by the
  4648                                  		;	 segment limit of the selector.
  4649                                  		;	 (Uses in run.asm always pass a segmented
  4650                                  		;	 address obtained from getsegmented. This
  4651                                  		;	 will have edxh = 0 always so it doesn't
  4652                                  		;	 matter whether we use edx or dx.)
  4653                                  		; OUT:	 al = value of byte read
  4654                                  readmem: section_of_function
  4655                                  %if _DEBUG1
  4656                                  	push dx
  4657                                  	push ax
  4658                                  
  4659                                  	call getlinear_high_limit.do_not_use_test	; NB do NOT resetmode
  4660                                  	jc @F			; already an error ?  then return --> (CY)
  4661                                  	push bx
  4662                                  	push cx
  4663                                  	mov bx, test_records_Readmem
  4664                                  	call handle_test_case_multiple_16
  4665                                  				; check whether this should testcase the error
  4666                                  				; CY to indicate error from this call
  4667                                  	pop cx
  4668                                  	pop bx
  4669                                  @@:
  4670                                  	pop ax
  4671                                  	pop dx
  4672                                  	jnc .do_not_use_test
  4673                                  	mov al, byte [test_readmem_value]
  4674                                  				; return a most likely wrong value
  4675                                  	retn
  4676                                  
  4677                                  %endif
  4678                                  .do_not_use_test:
  4679                                  
  4680                                  %if _PM
  4681                                  _386_PM	call test_high_limit	; 32-bit segment ?
  4682                                  	jz .16
  4683                                  [cpu 386]
  4684                                  	push ds
  4685                                  	mov ds, bx
  4686                                  ..@readmem_fault_skip_2_near_call:
  4687                                  	mov al, byte [edx]
  4688                                  	pop ds
  4689                                  	retn
  4690                                  __CPU__
  4691                                  .16:
  4692                                  %endif
  4693 00000AE7 1E                      	push ds
  4694 00000AE8 53                      	push bx
  4695 00000AE9 8EDB                    	mov ds, bx
  4696 00000AEB 89D3                    	mov bx, dx
  4697                                  ..@readmem_fault_skip_4_near_call:
  4698 00000AED 8A07                    	mov al, byte [bx]
  4699 00000AEF 5B                      	pop bx
  4700 00000AF0 1F                      	pop ds
  4701 00000AF1 C3                      	retn
  4702                                  
  4703                                  
  4704                                  %if !_LOADER
  4705                                  		; Q command - quit.
  4706                                  qq:
  4707 00000AF2 E889FC                  	call guard_re
  4708 00000AF5 31C9                    	xor cx, cx	; no qq mode selected
  4709 00000AF7 4E                      	dec si
  4710                                  .loop:
  4711 00000AF8 AC                      	lodsb
  4712 00000AF9 E8(0000)                	call capitalise
  4713 00000AFC 3C41                    	cmp al, 'A'
  4714 00000AFE 741C                    	je qq_a
  4715 00000B00 B501                    	mov ch, qqmode_b; QB mode (breakpoint before terminate)
  4716 00000B02 3C42                    	cmp al, 'B'
  4717 00000B04 7412                    	je .otherletter
  4718 00000B06 B502                    	mov ch, qqmode_c; QC mode (terminate device in a container MCB)
  4719 00000B08 3C43                    	cmp al, 'C'
  4720 00000B0A 740C                    	je .otherletter
  4721 00000B0C B504                    	mov ch, qqmode_d; QD mode (terminate device in initialisation)
  4722 00000B0E 3C44                    	cmp al, 'D'
  4723 00000B10 7406                    	je .otherletter
  4724 00000B12 880E[F513]              	mov byte [qq_mode], cl
  4725 00000B16 EB1B                    	jmp qq_default
  4726                                  
  4727                                  .otherletter:
  4728 00000B18 08E9                    	or cl, ch
  4729 00000B1A EBDC                    	jmp .loop
  4730                                  
  4731                                  	usesection lDEBUG_DATA_ENTRY
  4731          ------------------       note: usesection lDEBUG_DATA_ENTRY
  4732 000013F5 00                      qq_mode:	db 0
  4733                                  qqmode_b:	equ 1
  4734                                  qqmode_c:	equ 2
  4735                                  qqmode_d:	equ 4
  4736                                  	usesection lDEBUG_CODE
  4736          ------------------       note: usesection lDEBUG_CODE
  4737                                  
  4738                                  qq_a:
  4739 00000B1C AC                      	lodsb
  4740 00000B1D E8(0000)                	call chkeol
  4741 00000B20 E81007                  	call terminate_attached_process
  4742 00000B23 BB[0000]                	mov bx, msg.qq_a_unterminated
  4743 00000B26 7403                    	jz .attached_unterminated
  4744 00000B28 BB[0000]                	mov bx, msg.qq_a_terminated
  4745                                  .attached_unterminated:
  4746 00000B2B E8(0000)                	call putrunint
  4747 00000B2E 89DA                    	mov dx, bx
  4748 00000B30 E9(0000)                	jmp putsz
  4749                                  
  4750                                  
  4751                                  qq_default:
  4752 00000B33 E8(0000)                	call chkeol
  4753                                  
  4754                                  %if _RH
  4755 00000B36 8026[B601]EF            	clropt [options6], opt6_rh_mode
  4756 00000B3B 8026[E301]BF            	clropt [internalflags3], dif3_auxbuff_guarded_3
  4757 00000B40 8026[EE01]C7            	clropt [internalflags6], dif6_rh_mode_was | dif6_rh_mode | dif6_rh_mode_2
  4758                                  %endif
  4759 00000B45 E81AFC                  	call guard_auxbuff
  4760                                  
  4761                                  %if _DEVICE
  4762                                   %if _APPLICATION || _BOOTLDR
  4763 00000B48 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  4764 00000B4D 7411                    	jz .nondevice
  4765                                   %endif
  4766 00000B4F F6C106                  	test cl, qqmode_c | qqmode_d
  4767 00000B52 750C                    	jnz .deviceselected
  4768 00000B54 BA[0000]                	mov dx, msg.qq_device_none_selected
  4769 00000B57 B83701                  	mov ax, 0137h
  4770 00000B5A E8CB06                  	call setrc
  4771 00000B5D E9(0000)                	jmp putsz
  4772                                  
  4773                                  .deviceselected:
  4774                                  .nondevice:
  4775                                  %endif
  4776                                   %if _BOOTLDR
  4777                                  		; Test whether we are in non-DOS mode, and were
  4778                                  		; currently entered in protected mode. Since
  4779                                  		; this will make the entire operation fail,
  4780                                  		; it has to be checked for before modifying
  4781                                  		; or releasing any of the resources.
  4782                                  		; (Does this ever occur? No?)
  4783 00000B60 F606[D901]40            	testopt [internalflags], nodosloaded
  4784 00000B65 741A                    	jz .notpmnodos
  4785                                  %if _PM
  4786                                  	call ispm
  4787                                    %if _TSR	; same message, reuse code
  4788                                  	jz .cannotpmquit
  4789                                    %else
  4790                                  	jnz .notpmnodos_nodos
  4791                                  	mov dx, msg.cannotpmquit
  4792                                  	mov ax, 0115h
  4793                                  	call setrc
  4794                                  	jmp putsz_error
  4795                                    %endif
  4796                                  %endif
  4797                                  .notpmnodos_nodos:
  4798 00000B67 E8CA08                  	call bootgetmemorysize		; dx => behind usable memory
  4799 00000B6A A1[0000]                	mov ax, word [ boot_new_memsizekib ]
  4800 00000B6D B106                    	mov cl, 6
  4801 00000B6F D3E0                    	shl ax, cl
  4802 00000B71 39D0                    	cmp ax, dx			; same?
  4803 00000B73 740C                    	je @F
  4804 00000B75 BA[0000]                	mov dx, msg.cannotbootquit_memsizes
  4805 00000B78 B81B01                  	mov ax, 011Bh
  4806 00000B7B E8AA06                  	call setrc
  4807 00000B7E E9(0000)                	jmp .putsz
  4808                                  %if !_TSR || !_PM
  4809                                  	.putsz equ putsz
  4810                                  %endif
  4811                                  
  4812                                  @@:
  4813                                  .notpmnodos:
  4814                                   %endif
  4815                                  %if _PM
  4816                                   %if _TSR
  4817                                  		; Test whether we are in TSR mode, and were
  4818                                  		; currently entered in protected mode. Since
  4819                                  		; this will make the entire operation fail,
  4820                                  		; it has to be checked for before modifying
  4821                                  		; or releasing any of the resources.
  4822                                  	testopt [internalflags], tsrmode
  4823                                  	jz .notpmtsr
  4824                                  	call ispm
  4825                                  	jnz .notpmtsr
  4826                                  
  4827                                  ; This isn't yet implemented. Broken down:
  4828                                  ; * Uses terminate_attached_process which returns in real mode.
  4829                                  ;  * Exception vectors are implicitly restored/discarded by that.
  4830                                  ; * (RM) Interrupt vectors are currently restored in real mode. Unnecessary.
  4831                                  ; * The VDD is un-registered in real mode. Necessary?
  4832                                  ; * Normal 21.4C is used to return to the real parent.
  4833                                  ;  * We have to discard our DOS process resources. Any DPMI TSR resources?
  4834                                  ;  * We must again gain control in debuggee's mode after discarding them.
  4835                                  ;  * We must return to the debuggee and seemlessly discard our memory. The
  4836                                  ;    stack trick possibly/probably does not work in protected mode.
  4837                                  
  4838                                  .cannotpmquit:
  4839                                  	mov dx, msg.cannotpmquit
  4840                                  	mov ax, 0115h
  4841                                  	call setrc
  4842                                  .putsz:
  4843                                  	jmp putsz
  4844                                  
  4845                                  .notpmtsr:
  4846                                   %endif
  4847                                  
  4848                                   %if (opt4_int_2F_hook)&~0FFh
  4849                                    %fatal DCO4 re-ordered, adjust code here
  4850                                   %endif
  4851                                  	mov ax, [options4]
  4852                                   	mov ah, __TEST_IMM8
  4853                                  	xchg ah, [dpmidisable]		 	; disable DPMI hook
  4854                                  						; (SMC in section lDEBUG_DATA_ENTRY)
  4855                                  	push ax
  4856                                  	clropt [options4], opt4_int_2F_hook	; avoid a new hook while terminating
  4857                                  %endif
  4858                                  %else	; !_LOADER
  4859                                  qq:
  4860                                  	call chkeol
  4861                                  %endif
  4862                                  
  4863                                  qq_restore_interrupts_simulated:
  4864 00000B81 31ED                    	xor bp, bp
  4865                                  
  4866                                  %if _CATCHINT2D
  4867                                  .2D:
  4868 00000B83 B02D                    	mov al, 2Dh		; interrupt number
  4869 00000B85 BE[0000]                	mov si, int2D		; -> IISP entry header
  4870 00000B88 B93244                  	mov cx, "2D"
  4871 00000B8B BA0800                  	mov dx, opt4_int_2D_force >> 16
  4872                                   %if (opt4_int_2D_force >> 16) == dif4_int_2D_hooked
  4873 00000B8E E80306                  	call qq_int_unhook_sim.set_bx_to_dx
  4874                                   %else
  4875                                  	mov bx, dif4_int_2D_hooked
  4876                                  	call qq_int_unhook_sim
  4877                                   %endif
  4878                                  %endif
  4879                                  
  4880                                  
  4881                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  4882                                  .0D:
  4883 00000B91 B00D                    	mov al, 0Dh		; interrupt number
  4884 00000B93 BE[0000]                	mov si, intr0D		; -> IISP entry header
  4885 00000B96 B93044                  	mov cx, "0D"
  4886 00000B99 BA1000                  	mov dx, opt4_int_0D_force >> 16
  4887                                   %if (opt4_int_0D_force >> 16) == dif4_int_0D_hooked
  4888 00000B9C E8F505                  	call qq_int_unhook_sim.set_bx_to_dx
  4889                                   %else
  4890                                  	mov bx, dif4_int_0D_hooked
  4891                                  	call qq_int_unhook_sim
  4892                                   %endif
  4893                                  %endif
  4894                                  
  4895                                  
  4896                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  4897                                  .0C:
  4898 00000B9F B00C                    	mov al, 0Ch		; interrupt number
  4899 00000BA1 BE[0000]                	mov si, intr0C		; -> IISP entry header
  4900 00000BA4 B93043                  	mov cx, "0C"
  4901 00000BA7 BA2000                  	mov dx, opt4_int_0C_force >> 16
  4902                                   %if (opt4_int_0C_force >> 16) == dif4_int_0C_hooked
  4903 00000BAA E8E705                  	call qq_int_unhook_sim.set_bx_to_dx
  4904                                   %else
  4905                                  	mov bx, dif4_int_0C_hooked
  4906                                  	call qq_int_unhook_sim
  4907                                   %endif
  4908                                  %endif
  4909                                  
  4910                                  
  4911                                  %if _CATCHINT08
  4912                                  .08:
  4913 00000BAD B008                    	mov al, 08h		; interrupt number
  4914 00000BAF BE[0000]                	mov si, intr8		; -> IISP entry header
  4915 00000BB2 B93038                  	mov cx, "08"
  4916 00000BB5 BA0400                  	mov dx, opt4_int_08_force >> 16
  4917                                   %if (opt4_int_08_force >> 16) == dif4_int_08_hooked
  4918 00000BB8 E8D905                  	call qq_int_unhook_sim.set_bx_to_dx
  4919                                   %else
  4920                                  	mov bx, dif4_int_08_hooked
  4921                                  	call qq_int_unhook_sim
  4922                                   %endif
  4923                                  %endif
  4924                                  
  4925                                  
  4926                                  .serial:
  4927 00000BBB A0[980D]                	mov al, byte [serial_installed_intnum]
  4928 00000BBE BE[0000]                	mov si, serial_interrupt_handler
  4929 00000BC1 51                      	push cx			; (make space)
  4930 00000BC2 89E7                    	mov di, sp		; es:di -> word on stack
  4931 00000BC4 E8(0000)                	call hexbyte		; write byte value as text
  4932 00000BC7 59                      	pop cx			; cx = what to write into error message
  4933 00000BC8 BA0100                  	mov dx, opt4_int_serial_force >> 16
  4934                                   %if (opt4_int_serial_force >> 16) == dif4_int_serial_hooked
  4935 00000BCB E8C605                  	call qq_int_unhook_sim.set_bx_to_dx
  4936                                   %else
  4937                                  	mov bx, dif4_int_serial_hooked
  4938                                  	call qq_int_unhook_sim
  4939                                   %endif
  4940                                  
  4941                                  %if _PM
  4942                                  .2F:
  4943                                  	mov al, 2Fh		; interrupt number
  4944                                  	mov si, debug2F		; -> IISP entry header
  4945                                  	mov cx, "2F"
  4946                                  	mov dx, opt4_int_2F_force >> 16
  4947                                  	 testopt [internalflags], hooked2F
  4948                                  	 jz .noint2F
  4949                                  	call qq_int_unhook_sim.need
  4950                                  
  4951                                  .noint2F:
  4952                                  %endif
  4953                                  
  4954                                  
  4955                                  %if CATCHINTAMOUNT && ! (_DEBUG && ! _DEBUG_COND)
  4956                                   %if _DEBUG
  4957 00000BCE F606[ED01]01            	testopt [internalflags6], dif6_debug_mode
  4958 00000BD3 7530                    	jnz .skipints
  4959                                   %endif
  4960                                  		; Simulate to restore interrupt vectors.
  4961 00000BD5 BE[C00D]                	mov si, inttab
  4962 00000BD8 BF[D50D]                	mov di, intforcetab
  4963                                  %if _CATCHINT06 && _DETECT95LX
  4964 00000BDB 8B0E[DE0D]              	mov cx, word [inttab_number_variable]
  4965                                  %else
  4966                                  	mov cx, inttab_number
  4967                                  %endif
  4968 00000BDF E324                    	jcxz .intsimend
  4969 00000BE1 31D2                    	xor dx, dx
  4970                                  .nextintsim:
  4971 00000BE3 AC                      	lodsb
  4972 00000BE4 93                      	xchg ax, bx			; bl = number
  4973 00000BE5 AD                      	lodsw				; si -> list
  4974 00000BE6 96                      	xchg ax, si			; si -> entry, ax -> list
  4975 00000BE7 93                      	xchg ax, bx			; al = number, bx -> list
  4976 00000BE8 57                      	push di
  4977 00000BE9 8A35                    	mov dh, byte [di]
  4978 00000BEB E8(0000)                	call UnhookInterruptForceSim
  4979 00000BEE 5F                      	pop di
  4980 00000BEF 16                      	push ss
  4981 00000BF0 07                      	pop es
  4982 00000BF1 730D                    	jnc @F
  4983 00000BF3 BF[0000]                	mov di, msg.serial_cannot_unhook.int
  4984 00000BF6 E8(0000)                	call hexbyte
  4985 00000BF9 BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  4986 00000BFC E8(0000)                	call putsz
  4987 00000BFF 45                      	inc bp
  4988                                  @@:
  4989 00000C00 47                      	inc di
  4990 00000C01 87DE                    	xchg bx, si			; si -> list
  4991 00000C03 E2DE                    	loop .nextintsim
  4992                                  
  4993                                  .intsimend:
  4994                                  .skipints:
  4995                                  %endif
  4996                                  
  4997 00000C05 BA[0000]                	mov dx, msg.empty_message
  4998 00000C08 85ED                    	test bp, bp
  4999 00000C0A 7403E92C03              	jnz qq_attached_unterminated.common
  5000                                  
  5001                                  
  5002                                  %if _DEVICE
  5003                                  qq_device_prepare:
  5004                                   %if _APPLICATION || _BOOTLDR
  5005 00000C0F F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  5006 00000C14 7503E99C01              	jz qq_nondevice
  5007                                   %endif
  5008                                  
  5009                                  %if _PM
  5010                                  	mov dx, msg.qq_device_pm
  5011                                  	call ispm
  5012                                  	jz @F			; in PM -->
  5013                                  %endif
  5014                                  
  5015                                  		; Try quitting early in device init ?
  5016 00000C19 F606[F513]04            	testopt [qq_mode], qqmode_d
  5017 00000C1E 743D                    	jz .device_c		; no, must be container quit -->
  5018                                  
  5019                                  .device_d:
  5020 00000C20 F606[DA01]40            	testopt [internalflags], tsrmode
  5021 00000C25 741E                    	jz .check_device_c
  5022                                  
  5023 00000C27 BE[F80D]                	mov si, regs
  5024 00000C2A BF[780E]                	mov di, device_quittable_regs
  5025 00000C2D B92000                  	mov cx, words(regs.size)
  5026 00000C30 F3A7                    	repe cmpsw		; can quit to device init ?
  5027 00000C32 7511                    	jne .check_device_c
  5028 00000C34 C43E[940D]              	les di, [device_header_address]
  5029 00000C38 B0FF                    	mov al, -1
  5030 00000C3A B104                    	mov cl, 4
  5031 00000C3C F3AE                    	repe scasb		; is next device pointer still -1 ?
  5032 00000C3E 16                      	push ss
  5033 00000C3F 07                      	pop es
  5034 00000C40 7503E97001              	je qq_device_got	; yes -->
  5035                                  
  5036                                  .check_device_c:
  5037                                  		; Cannot quit to device init. Clear the flag
  5038                                  		;  so we know later on that we're trying QC.
  5039 00000C45 8026[F513]FB            	clropt [qq_mode], qqmode_d
  5040 00000C4A F606[F513]02            	testopt [qq_mode], qqmode_c
  5041                                  				; actually want to try QC ?
  5042 00000C4F 750C                    	jnz .device_c		; yes -->
  5043                                  
  5044 00000C51 BA[0000]                	mov dx, msg.qq_device_no_d
  5045 00000C54 B82101                  	mov ax, 0121h
  5046 00000C57 E8CE05                  	call setrc
  5047                                  @@:
  5048 00000C5A E9DE02                  	jmp qq_attached_unterminated.common
  5049                                  
  5050                                  .device_c:
  5051 00000C5D B80258                  	mov ax, 5802h
  5052 00000C60 CD21                    	int 21h
  5053 00000C62 B400                    	mov ah, 0
  5054 00000C64 50                      	push ax			; preserve UMB link
  5055 00000C65 B80358                  	mov ax, 5803h
  5056 00000C68 BB0100                  	mov bx, 1
  5057 00000C6B CD21                    	int 21h			; enable UMB link
  5058                                  				;  we want to support the case in which
  5059                                  				;  the first UMCB may have changed. so
  5060                                  				;  instead of searching for it again we
  5061                                  				;  just request the link enabled.
  5062                                  
  5063 00000C6D BBFFFF                  	mov bx, -1
  5064 00000C70 B452                    	mov ah, 52h
  5065 00000C72 CD21                    	int 21h
  5066 00000C74 89DF                    	mov di, bx
  5067 00000C76 83FBBE                  	cmp bx, - (30h + 12h)
  5068 00000C79 7603E91E01              	ja .no_c
  5069 00000C7E 83FB01                  	cmp bx, 1
  5070 00000C81 7503E91601              	je .no_c
  5071 00000C86 268B57FE                	mov dx, word [es:bx - 2]
  5072 00000C8A B93000                  	mov cx, 30h
  5073                                  
  5074                                  .nulloop:
  5075 00000C8D BE[0000]                	mov si, msg.NULblank
  5076 00000C90 A7                      	cmpsw			; di += 2, si += 2. compare
  5077 00000C91 750A                    	jne .nulnext
  5078                                  .nulcheck:
  5079 00000C93 57                      	push di
  5080 00000C94 51                      	push cx
  5081 00000C95 B103                    	mov cl, 3		; 3 more words to go
  5082 00000C97 F3A7                    	repe cmpsw		; match ?
  5083 00000C99 59                      	pop cx
  5084 00000C9A 5F                      	pop di
  5085 00000C9B 7406                    	je .nulfound
  5086                                  .nulnext:
  5087 00000C9D 4F                      	dec di			; di -= 1 so it ends up 1 higher than prior
  5088 00000C9E E2ED                    	loop .nulloop
  5089 00000CA0 E9F900                  	jmp .no_c
  5090                                  
  5091                                  .nulfound:
  5092 00000CA3 83EF0C                  	sub di, 3 * 2 + 4 + 2	; (strategy, interrupt, flags are words,
  5093                                  				;  next device pointer is a dword.
  5094                                  				;  additional plus 2 for the cmpsw output.)
  5095                                  
  5096                                  		; es:di -> NUL device header
  5097                                  .devloop:
  5098 00000CA6 A1[940D]                	mov ax, word [device_header_address]
  5099 00000CA9 263B05                  	cmp ax, word [es:di]
  5100 00000CAC 7509                    	jne .devnext
  5101 00000CAE A1[960D]                	mov ax, word [device_header_address + 2]
  5102 00000CB1 263B4502                	cmp ax, word [es:di + 2]
  5103 00000CB5 7411                    	je .mcb
  5104                                  .devnext:
  5105 00000CB7 41                      	inc cx
  5106 00000CB8 7903E9DF00              	js .no_c
  5107                                  
  5108 00000CBD 26C43D                  	les di, [es:di]
  5109 00000CC0 83FFFF                  	cmp di, -1
  5110 00000CC3 75E1                    	jne .devloop
  5111 00000CC5 E9D400                  	jmp .no_c
  5112                                  
  5113                                  .mcb:
  5114                                  
  5115 00000CC8 893E[F813]              	mov word [.device_reference], di
  5116 00000CCC 8C06[FA13]              	mov word [.device_reference + 2], es
  5117                                  
  5118 00000CD0 8326[0214]00            	and word [.counter], 0
  5119 00000CD5 89C7                    	mov di, ax		; => start of memory allocated to us
  5120 00000CD7 8B0E[920D]              	mov cx, word [device_mcb_paragraphs]
  5121                                  				; = amount paragraphs allocated to us
  5122 00000CDB 01CF                    	add di, cx		; => behind memory allocated to us
  5123                                  
  5124                                  		; dx => first MCB
  5125                                  .mcbloop:
  5126 00000CDD 8EC2                    	mov es, dx
  5127 00000CDF 89D6                    	mov si, dx		; => MCB
  5128 00000CE1 2603360300              	add si, word [es:3]
  5129 00000CE6 46                      	inc si			; => next MCB (or behind current MCB)
  5130 00000CE7 26803E00004D            	cmp byte [es:0], 'M'	; valid MCB ?
  5131 00000CED 740B                    	je @F
  5132 00000CEF 26803E00005A            	cmp byte [es:0], 'Z'
  5133 00000CF5 7403E9A200              	jne .no_c		; no -->
  5134                                  @@:
  5135 00000CFA 39C2                    	cmp dx, ax		; start of MCB < allocation ?
  5136 00000CFC 731F                    	jae .mcbnext		; no -->
  5137 00000CFE 39FE                    	cmp si, di		; end of MCB > allocation ?
  5138 00000D00 721B                    	jb .mcbnext		; no -->
  5139                                  
  5140 00000D02 26833E010000            	cmp word [es:1], 0	; free ?
  5141 00000D08 7413                    	je .mcbnext		; do not match -->
  5142 00000D0A 48                      	dec ax			; => our (sub) MCB
  5143 00000D0B 39C2                    	cmp dx, ax		; matches (DEVLOAD style) ?
  5144 00000D0D 7520                    	jne .mcbcontainer	; no -->
  5145 00000D0F 26390E0300              	cmp word [es:3], cx	; size matches ?
  5146 00000D14 7519                    	jne .mcbcontainer	; no -->
  5147 00000D16 8326[FC13]00            	and word [.container_segment], 0
  5148 00000D1B EB7E                    	jmp .mcbdone		; found a non-container MCB
  5149                                  
  5150                                  .mcbnext:
  5151 00000D1D FF06[0214]              	inc word [.counter]	; safeguard against infinite loop
  5152 00000D21 7479                    	jz .no_c
  5153 00000D23 89F2                    	mov dx, si		; => next MCB
  5154 00000D25 26803E00004D            	cmp byte [es:0], 'M'	; prior was 'M' ?
  5155 00000D2B 74B0                    	je .mcbloop		; yes, so loop -->
  5156 00000D2D EB6D                    	jmp .no_c
  5157                                  
  5158                                  .mcbcontainer:
  5159 00000D2F 40                      	inc ax			; => allocated block (device header)
  5160 00000D30 26833E010050            	cmp word [es:1], 50h	; SD owner system ?
  5161 00000D36 73E5                    	jae .mcbnext
  5162 00000D38 26813E08005344          	cmp word [es:8], "SD"
  5163 00000D3F 75DC                    	jne .mcbnext		; no -->
  5164                                  
  5165 00000D41 26FF360000              	push word [es:0]
  5166 00000D46 8F06[0014]              	pop word [.container_is_z]
  5167 00000D4A 8936[FE13]              	mov word [.container_end], si
  5168 00000D4E 8916[FC13]              	mov word [.container_segment], dx
  5169 00000D52 42                      	inc dx			; => sub-MCB
  5170                                  .submcbloop:
  5171 00000D53 8EC2                    	mov es, dx
  5172 00000D55 89D6                    	mov si, dx
  5173 00000D57 2603360300              	add si, word [es:3]
  5174 00000D5C 46                      	inc si			; => next sub or MCB (or behind Z MCB)
  5175 00000D5D 39C2                    	cmp dx, ax
  5176 00000D5F 731C                    	jae .submcbnext
  5177 00000D61 39FE                    	cmp si, di
  5178 00000D63 7218                    	jb .submcbnext
  5179                                  
  5180 00000D65 50                      	push ax
  5181 00000D66 48                      	dec ax			; => our (sub) MCB
  5182 00000D67 39C2                    	cmp dx, ax		; matched start of allocation ?
  5183 00000D69 58                      	pop ax
  5184 00000D6A 7511                    	jne .submcbnext
  5185 00000D6C 26390E0300              	cmp word [es:3], cx	; matches allocation size ?
  5186 00000D71 750A                    	jne .submcbnext
  5187 00000D73 26833E010000            	cmp word [es:1], 0	; is not free ?
  5188 00000D79 7402                    	je .submcbnext
  5189 00000D7B EB1E                    	jmp .mcbdone		; all yes, found it -->
  5190                                  
  5191                                  .submcbnext:
  5192 00000D7D FF06[0214]              	inc word [.counter]	; safeguard against infinite loop
  5193 00000D81 7419                    	jz .no_c
  5194 00000D83 89F2                    	mov dx, si		; => next sub MCB or after container
  5195 00000D85 8B36[FE13]              	mov si, word [.container_end]
  5196 00000D89 39F2                    	cmp dx, si		; after container ?
  5197 00000D8B 72C6                    	jb .submcbloop		; no -->
  5198                                  		; This jump could be a jne but generally
  5199                                  		;  we can assume that the container does
  5200                                  		;  not overflow across the 1 MiB limit.
  5201                                  		; And this is more hardened against errors.
  5202 00000D8D 89F2                    	mov dx, si		; insure we use actual container end
  5203 00000D8F 803E[0014]5A            	cmp byte [.container_is_z], 'Z'
  5204                                  				; container had a Z ?
  5205 00000D94 7403E944FF              	jne .mcbloop		; no -->
  5206                                  		; if here, loop now, dx already updated and
  5207                                  		;  furthermore es does not point at container!
  5208 00000D99 EB01                    	jmp .no_c
  5209                                  
  5210                                  	usesection lDEBUG_DATA_ENTRY
  5210          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5211 000013F6 00<rep 2h>              	align 4, db 0
  5212 000013F8 00000000                .device_reference:	dd 0
  5213 000013FC 0000                    .container_segment:	dw 0
  5214 000013FE 0000                    .container_end:		dw 0
  5215 00001400 0000                    .container_is_z:	dw 0
  5216 00001402 0000                    .counter:		dw 0
  5217                                  	usesection lDEBUG_CODE
  5217          ------------------       note: usesection lDEBUG_CODE
  5218                                  
  5219                                  .mcbdone:
  5220                                  
  5221 00000D9B A8                      	db __TEST_IMM8		; (skip stc, NC)
  5222                                  .no_c:
  5223 00000D9C F9                      	stc
  5224 00000D9D 5B                      	pop bx
  5225 00000D9E 9C                      	pushf
  5226 00000D9F B80358                  	mov ax, 5803h
  5227 00000DA2 CD21                    	int 21h			; restore UMB link
  5228 00000DA4 9D                      	popf
  5229 00000DA5 16                      	push ss
  5230 00000DA6 07                      	pop es
  5231 00000DA7 730C                    	jnc @F
  5232 00000DA9 BA[0000]                	mov dx, msg.qq_device_no_c
  5233 00000DAC B82201                  	mov ax, 0122h
  5234 00000DAF E87604                  	call setrc
  5235 00000DB2 E98601                  	jmp qq_attached_unterminated.common
  5236                                  
  5237                                  @@:
  5238                                  
  5239                                  qq_device_got:
  5240                                  qq_nondevice:
  5241                                  %endif
  5242                                  
  5243                                  
  5244                                  qq_restore_interrupts:
  5245                                  %if _CATCHINT2D
  5246                                  .2D:
  5247 00000DB5 B02D                    	mov al, 2Dh		; interrupt number
  5248 00000DB7 BE[0000]                	mov si, int2D		; -> IISP entry header
  5249 00000DBA B93244                  	mov cx, "2D"
  5250 00000DBD BA0800                  	mov dx, opt4_int_2D_force >> 16
  5251                                   %if (opt4_int_2D_force >> 16) == dif4_int_2D_hooked
  5252 00000DC0 E8ED03                  	call qq_int_unhook_real.set_bx_to_dx
  5253                                   %else
  5254                                  	mov bx, dif4_int_2D_hooked
  5255                                  	call qq_int_unhook_real
  5256                                   %endif
  5257 00000DC3 7303E97301              	jc qq_attached_unterminated.common
  5258                                  %endif
  5259                                  
  5260                                  
  5261                                  %if _CATCHINTFAULTCOND && _CATCHINT0D
  5262                                  .0D:
  5263 00000DC8 B00D                    	mov al, 0Dh		; interrupt number
  5264 00000DCA BE[0000]                	mov si, intr0D		; -> IISP entry header
  5265 00000DCD B93044                  	mov cx, "0D"
  5266 00000DD0 BA1000                  	mov dx, opt4_int_0D_force >> 16
  5267                                   %if (opt4_int_0D_force >> 16) == dif4_int_0D_hooked
  5268 00000DD3 E8DA03                  	call qq_int_unhook_real.set_bx_to_dx
  5269                                   %else
  5270                                  	mov bx, dif4_int_0D_hooked
  5271                                  	call qq_int_unhook_real
  5272                                   %endif
  5273 00000DD6 7303E96001              	jc qq_attached_unterminated.common
  5274                                  %endif
  5275                                  
  5276                                  
  5277                                  %if _CATCHINTFAULTCOND && _CATCHINT0C
  5278                                  .0C:
  5279 00000DDB B00C                    	mov al, 0Ch		; interrupt number
  5280 00000DDD BE[0000]                	mov si, intr0C		; -> IISP entry header
  5281 00000DE0 B93043                  	mov cx, "0C"
  5282 00000DE3 BA2000                  	mov dx, opt4_int_0C_force >> 16
  5283                                   %if (opt4_int_0C_force >> 16) == dif4_int_0C_hooked
  5284 00000DE6 E8C703                  	call qq_int_unhook_real.set_bx_to_dx
  5285                                   %else
  5286                                  	mov bx, dif4_int_0C_hooked
  5287                                  	call qq_int_unhook_real
  5288                                   %endif
  5289 00000DE9 7303E94D01              	jc qq_attached_unterminated.common
  5290                                  %endif
  5291                                  
  5292                                  
  5293                                  %if _CATCHINT08
  5294                                  .08:
  5295 00000DEE B008                    	mov al, 08h		; interrupt number
  5296 00000DF0 BE[0000]                	mov si, intr8		; -> IISP entry header
  5297 00000DF3 B93038                  	mov cx, "08"
  5298 00000DF6 BA0400                  	mov dx, opt4_int_08_force >> 16
  5299                                   %if (opt4_int_08_force >> 16) == dif4_int_08_hooked
  5300 00000DF9 E8B403                  	call qq_int_unhook_real.set_bx_to_dx
  5301                                   %else
  5302                                  	mov bx, dif4_int_08_hooked
  5303                                  	call qq_int_unhook_real
  5304                                   %endif
  5305 00000DFC 7303E93A01              	jc qq_attached_unterminated.common
  5306                                  %endif
  5307                                  
  5308                                  
  5309                                  .serial:
  5310 00000E01 F606[690D]01            	testopt [serial_flags], sf_init_done
  5311 00000E06 740D                    	jz @F
  5312 00000E08 E8(0000)                	call serial_clean_up			; unhook interrupt
  5313 00000E0B 8026[690D]EE            	clropt [serial_flags], sf_init_done | sf_use_serial
  5314                                  						; clear (in case return to cmd3)
  5315 00000E10 8026[A101]BF            	clropt [options], enable_serial		; do not output to serial any longer
  5316                                  @@:
  5317 00000E15 F606[E401]01            	testopt [internalflags4], dif4_int_serial_hooked
  5318 00000E1A 741F                    	jz .done_serial
  5319 00000E1C E8(0000)                	call serial_uninstall_interrupt_handler
  5320 00000E1F 731A                    	jnc .done_serial			; if it succeeded -->
  5321                                  
  5322 00000E21 BF[0000]                	mov di, msg.serial_cannot_unhook.int
  5323 00000E24 A0[980D]                	mov al, byte [serial_installed_intnum]
  5324 00000E27 E8(0000)                	call hexbyte
  5325 00000E2A BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  5326 00000E2D C606[0800]00            	mov byte [serial_interrupt_handler + ieEOI], 0
  5327                                  						; we do not issue EOI any longer
  5328 00000E32 B82301                  	mov ax, 0123h
  5329 00000E35 E8F003                  	call setrc
  5330 00000E38 E90001                  	jmp qq_attached_unterminated.common
  5331                                  
  5332                                  
  5333                                  .done_serial:
  5334                                  
  5335                                  %if _PM
  5336                                  .2F:
  5337                                  	mov al, 2Fh		; interrupt number
  5338                                  	mov si, debug2F		; -> IISP entry header
  5339                                  	mov cx, "2F"
  5340                                  	mov dx, opt4_int_2F_force >> 16
  5341                                   %if (opt4_int_2F_force >> 16) == dif4_int_2F_hooked
  5342                                  	mov bx, dx
  5343                                   %else
  5344                                  	mov bx, dif4_int_2F_hooked
  5345                                   %endif
  5346                                  	 testopt [internalflags], hooked2F
  5347                                  	 jz .noint2F
  5348                                  	call qq_int_unhook_real.need
  5349                                  	jc qq_attached_unterminated.common
  5350                                  
  5351                                  .got2F:
  5352                                  	clropt [internalflags], hooked2F
  5353                                  
  5354                                  .noint2F:
  5355                                  %endif
  5356                                  
  5357                                  %if _LOADER
  5358                                  	int 19h
  5359                                  %else ; _LOADER
  5360                                  %if _BOOTLDR
  5361                                   %if _APPLICATION || _DEVICE
  5362 00000E3B F606[D901]40            	testopt [internalflags], nodosloaded
  5363 00000E40 7511                    	jnz .areas
  5364                                   %else
  5365                                  	jmp .areas
  5366                                   %endif
  5367                                  %endif
  5368                                  
  5369                                  
  5370                                  %if _APPLICATION || _DEVICE
  5371                                  		; Cancel child's process if any.
  5372                                  		; This will drop to real mode if debuggee is in protected mode.
  5373                                  %if _TSR || _DEVICE
  5374 00000E42 F606[DA01]40            	testopt [internalflags], tsrmode
  5375 00000E47 7402                    	jz .terminate_attached	; falls through for device or TSR application
  5376                                  
  5377                                  %if _PM
  5378                                  	call ispm
  5379                                  	jz @F			; in PM -->
  5380                                  	testopt [internalflags], canswitchmode
  5381                                  	jz @FF			; in 86 Mode and cannot switch to PM -->
  5382                                  
  5383                                  	setopt [internalflags], modeswitched	; set flag for resetmode
  5384                                  	mov al, 0
  5385                                  	call sr_state		; save state
  5386                                  	call switchmode 	; switch to PM
  5387                                  		; ! handle_mode_changed not called here !
  5388                                  		; do not call InDOS or other functions using seg/sels
  5389                                  @@:
  5390                                  	call pm_reset_handlers
  5391                                  		; ! this calls resetmode
  5392                                  
  5393                                  		; remember that we cannot access Protected Mode any longer
  5394                                  	clropt [internalflags], canswitchmode | switchbuffer
  5395                                  @@:
  5396                                  %endif
  5397                                  
  5398 00000E49 EB08                    	jmp .areas
  5399                                  
  5400                                  .terminate_attached:
  5401                                  %endif
  5402                                  
  5403 00000E4B E8E503                  	call terminate_attached_process
  5404 00000E4E 7503E9DC00              	jz qq_attached_unterminated
  5405                                  %if _PM
  5406                                  	call ispm
  5407                                  	jnz @F
  5408                                  
  5409                                  	mov dx, msg.qq_still_pm
  5410                                  	mov ax, 0124h
  5411                                  	call setrc
  5412                                  	jmp qq_attached_unterminated.common
  5413                                  @@:
  5414                                  %endif
  5415                                  %endif
  5416                                  
  5417                                  
  5418                                  .areas:
  5419                                  %if _AREAS && _AREAS_HOOK_CLIENT
  5420                                  	call uninstall_areas.qq_entry
  5421                                   %if _AREAS_HOOK_SERVER
  5422                                  	jc .areas_error
  5423                                   %else
  5424                                  	jnc @F
  5425                                  	mov dx, msg.qqlate_areas_error
  5426                                  	mov ax, 0125h
  5427                                  	call setrc
  5428                                  	jmp qq_attached_unterminated.common
  5429                                   %endif
  5430                                  %endif
  5431                                  
  5432                                  @@:
  5433                                  %if _AREAS_HOOK_SERVER
  5434                                  	mov dx, word [ddebugareas.next + 2]
  5435                                  	mov bx, word [ddebugareas.next]
  5436                                  	mov ax, ss
  5437                                  	cmp dx, ax
  5438                                  	je @F
  5439                                  	 push dx
  5440                                  	 push bx
  5441                                  	mov al, 0
  5442                                  	push cs
  5443                                  	call qqlate_86m_to_areastruc_entry
  5444                                  	push ss
  5445                                  	pop ds
  5446                                  	push ss
  5447                                  	pop es
  5448                                  	 pop bx
  5449                                  	 pop dx
  5450                                  	cmp dx, word [ddebugareas.next + 2]
  5451                                  	jne @B
  5452                                  	cmp bx, word [ddebugareas.next]
  5453                                  	jne @B
  5454                                  .areas_error:
  5455                                  	mov dx, msg.qqlate_areas_error
  5456                                  	mov ax, 0125h
  5457                                  	call setrc
  5458                                  	jmp qq_attached_unterminated.common
  5459                                  
  5460                                  @@:
  5461                                  %endif
  5462                                  
  5463                                  
  5464                                  .restoreints:
  5465                                  %if CATCHINTAMOUNT && ! (_DEBUG && ! _DEBUG_COND)
  5466                                   %if _DEBUG
  5467 00000E53 F606[ED01]01            	testopt [internalflags6], dif6_debug_mode
  5468 00000E58 751F                    	jnz .skiprestoreints
  5469                                   %endif
  5470                                  		; Restore interrupt vectors.
  5471 00000E5A BE[C00D]                	mov si, inttab
  5472 00000E5D BF[D50D]                	mov di, intforcetab
  5473                                  %if _CATCHINT06 && _DETECT95LX
  5474 00000E60 8B0E[DE0D]              	mov cx, word [inttab_number_variable]
  5475                                  %else
  5476                                  	mov cx, inttab_number
  5477                                  %endif
  5478 00000E64 E313                    	jcxz .intend
  5479 00000E66 31D2                    	xor dx, dx
  5480                                  .nextint:
  5481 00000E68 AC                      	lodsb
  5482 00000E69 93                      	xchg ax, bx			; bl = number
  5483 00000E6A AD                      	lodsw				; si -> list
  5484 00000E6B 96                      	xchg ax, si			; si -> entry, ax -> list
  5485 00000E6C 93                      	xchg ax, bx			; al = number, bx -> list
  5486 00000E6D 57                      	push di
  5487 00000E6E 8A35                    	mov dh, byte [di]
  5488 00000E70 E8(0000)                	call UnhookInterruptForce
  5489 00000E73 5F                      	pop di
  5490 00000E74 47                      	inc di
  5491 00000E75 87DE                    	xchg bx, si			; si -> list
  5492 00000E77 E2EF                    	loop .nextint
  5493                                  
  5494                                  .intend:
  5495                                  .skiprestoreints:
  5496                                  %endif
  5497                                  
  5498                                  
  5499                                  %if _PM
  5500                                  	pop ax					; (discard)
  5501                                  %endif
  5502                                  
  5503                                  
  5504                                  qqlate:
  5505                                  %if _SYMBOLIC
  5506                                  		; Free XMS symbol table. 86 Mode memory backed symbol table
  5507                                  		;  is freed by our process's termination.
  5508                                  		; Update: QD device termination does not currently terminate
  5509                                  		;  our process. In the meantime, free things explicitly.
  5510                                  		;  Note that the calls need to be in this order because of
  5511                                  		;  how zz_free_xms calls zz_free_reset first.
  5512                                  	nearcall zz_free_dos
  5513                                  	nearcall zz_free_xms
  5514                                  %endif
  5515                                  
  5516                                  		; Release the registered VDD.
  5517                                  %if _VDD
  5518 00000E79 F606[D801]04            	testopt [internalflags], ntpacket
  5519 00000E7E 7408                    	jz .novdd
  5520 00000E80 A1[580C]                	mov ax, word [hVdd]
  5521 00000E83 C4C4580190              	UnRegisterModule
  5522                                  .novdd:
  5523                                  %endif
  5524                                  
  5525                                  %if _VXCHG
  5526 00000E88 F606[EC01]01            	testopt [internalflags6], dif6_vv_mode
  5527 00000E8D 7403                    	jz @F
  5528                                  
  5529 00000E8F E8(0000)                	call vv_disable
  5530                                  @@:
  5531                                  %endif
  5532                                  
  5533                                  %if _ALTVID
  5534 00000E92 E8(0000)                	call setscreen
  5535                                  %endif
  5536                                  
  5537                                  		; Restore termination address.
  5538                                  %if _BOOTLDR
  5539                                   %if _APPLICATION || _DEVICE
  5540 00000E95 F606[D901]40            	testopt [internalflags], nodosloaded
  5541 00000E9A 7403E99701              	jnz .bootterminate	; terminate -->
  5542                                   %else
  5543                                  	jmp .bootterminate
  5544                                   %endif
  5545                                  %endif
  5546                                  %if _DEVICE
  5547                                   %if _APPLICATION
  5548 00000E9F F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  5549 00000EA4 7403E99B00              	jnz .deviceterminate
  5550                                   %else
  5551                                  	jmp .deviceterminate
  5552                                   %endif
  5553                                  %endif
  5554                                  
  5555                                  %if _APPLICATION || _DEVICE
  5556                                  %if _TSR || _DEVICE
  5557                                  .appterminate:
  5558 00000EA9 16                      	 push ss
  5559 00000EAA 07                      	 pop es
  5560 00000EAB F606[DA01]40            	testopt [internalflags], tsrmode
  5561 00000EB0 745D                    	jz .nontsrterminate
  5562                                  
  5563                                  .tsrterminate:
  5564 00000EB2 BA[1514]                	mov dx, qq.proceedtsrtermination
  5565                                  
  5566                                  .terminate_to_shim_process:
  5567 00000EB5 31F6                    	xor si, si
  5568 00000EB7 8E06[8A0B]              	mov es, word [auxbuff_segorsel]
  5569 00000EBB 31FF                    	xor di, di
  5570 00000EBD 31C0                    	xor ax, ax
  5571 00000EBF B90800                  	mov cx, 8
  5572 00000EC2 F3AB                    	rep stosw		; 10h MCB bytes
  5573 00000EC4 B94000                  	mov cx, 40h
  5574 00000EC7 F3A5                    	rep movsw		; 80h PSP bytes
  5575 00000EC9 8CC0                    	mov ax, es
  5576 00000ECB 40                      	inc ax
  5577 00000ECC 26A30100                	mov word [es:1], ax	; fake MCB
  5578 00000ED0 1E                      	push ds
  5579 00000ED1 8ED8                    	mov ds, ax
  5580 00000ED3 C70634001800            	mov word [34h], 18h
  5581 00000ED9 A33600                  	mov word [36h], ax	; insure default PHT and fix segment
  5582 00000EDC C70632000100            	mov word [32h], 1	; only one PHT entry (zero might crash)
  5583 00000EE2 C6061800FF              	mov byte [18h], -1	; PHT entry is closed
  5584 00000EE7 C7062C000000            	mov word [2Ch], 0	; PSP clear
  5585 00000EED E83A01                  	call .setparent		; make it self-owned, just in case
  5586 00000EF0 8CD3                    	mov bx, ss		; => process segment
  5587 00000EF2 4B                      	dec bx			; span actual MCB
  5588                                  %if _DEVICE
  5589                                   %if _APPLICATION
  5590 00000EF3 36F606[EE01]40          	testopt [ss:internalflags6], dif6_device_mode
  5591 00000EF9 7403                    	jz @F
  5592                                   %endif
  5593 00000EFB 83EB04                  	sub bx, deviceshim_size_p + paras(10h)
  5594                                  				; span shim and pseudo MCB
  5595                                  @@:
  5596                                  %endif
  5597 00000EFE 8EDB                    	mov ds, bx		; => our (real) MCB
  5598 00000F00 81FA[1514]              	cmp dx, qq.proceedtsrtermination
  5599 00000F04 7503                    	jne @F
  5600 00000F06 A30100                  	mov word [1], ax	; owner = fake PSP
  5601                                  @@:
  5602 00000F09 1F                      	pop ds
  5603 00000F0A E81D01                  	call .setparent		; make the fake PSP our parent
  5604 00000F0D EB1B                    	jmp short terminate_00	; see ya
  5605                                  
  5606                                  .nontsrterminate:
  5607                                  %endif
  5608 00000F0F BE[680C]                	mov si, psp22		; restore termination address
  5609 00000F12 BF0A00                  	mov di, TPIV
  5610 00000F15 A5                      	movsw
  5611 00000F16 A5                      	movsw
  5612 00000F17 BF1600                  	mov di, 16h		; restore PSP of parent
  5613 00000F1A A5                      	movsw
  5614                                  		; Really done.
  5615                                  
  5616 00000F1B F606[F513]01            	testopt [qq_mode], qqmode_b
  5617 00000F20 7401                    	jz @F
  5618 00000F22 CC                      	int3
  5619                                  
  5620                                  @@:
  5621 00000F23 B44C                    	mov ah, 4Ch		; quit
  5622 00000F25 A0[910D]                	mov al, byte [qqtermcode]
  5623                                  				; return code
  5624 00000F28 CD21                    	int 21h
  5625                                  %endif
  5626                                  
  5627                                  
  5628                                  terminate_00:	; used by terminate_attached_process
  5629 00000F2A B8004C                  	mov ax, 4C00h		; quit
  5630 00000F2D CD21                    	int 21h
  5631                                  
  5632                                  
  5633                                  %if _AREAS_HOOK_SERVER
  5634                                  qqlate_86m_to_areastruc_entry:
  5635                                  	mov cx, areastruc_entry.qq_entry
  5636                                  	push ss
  5637                                  	push cx
  5638                                  	retf
  5639                                  %endif
  5640                                  %endif	; !_LOADER
  5641                                  
  5642                                  
  5643                                  qq_attached_unterminated:
  5644                                  %if !_LOADER
  5645 00000F2F E8(0000)                	call putrunint
  5646                                  %endif	; !_LOADER
  5647 00000F32 BA[0000]                	mov dx, msg.qq_unterm
  5648 00000F35 B82001                  	mov ax, 0120h
  5649 00000F38 E8ED02                  	call setrc
  5650                                  
  5651                                  .common:
  5652 00000F3B B81F01                  	mov ax, 011Fh
  5653 00000F3E E8E702                  	call setrc
  5654                                  		; Restore state:
  5655                                  %if _PM
  5656                                   %if (opt4_int_2F_hook)&~0FFh
  5657                                    %fatal DCO4 re-ordered, adjust code here
  5658                                   %endif
  5659                                   	pop ax
  5660                                  	mov [dpmidisable], ah	; (SMC in section lDEBUG_DATA_ENTRY)
  5661                                  	and al, opt4_int_2F_hook
  5662                                  	clropt [options4], opt4_int_2F_hook
  5663                                  	or [options4], al
  5664                                  %endif
  5665 00000F41 E9(0000)                	jmp putsz
  5666                                  
  5667                                  
  5668                                  %if !_LOADER
  5669                                  %if _DEVICE
  5670                                  qqlate.deviceterminate:
  5671 00000F44 F606[F513]04            	testopt [qq_mode], qqmode_d
  5672 00000F49 7438                    	jz .mode_c
  5673                                  
  5674                                  .mode_d:
  5675                                  		; We modify the device request header
  5676                                  		;  only now, so in case of being unable
  5677                                  		;  to release something then the debugger
  5678                                  		;  will remain usable and stay resident.
  5679 00000F4B 8E06[1C0E]              	mov es, word [reg_es]
  5680 00000F4F 8B1E[FC0D]              	mov bx, word [reg_ebx]
  5681 00000F53 8CD8                    	mov ax, ds			; => process segment
  5682 00000F55 83E804                  	sub ax, paras(deviceshim_size + 10h)
  5683                                  					; span shim and pseudo MCB
  5684 00000F58 26C747030381            	mov word [es:bx + 3], 8103h	; error, done, code: unknown command
  5685 00000F5E 2683670E00              	and word [es:bx + 0Eh], 0
  5686 00000F63 26894710                	mov word [es:bx + 0Eh + 2], ax	; -> behind memory in use
  5687                                  		; es reset in run or qqlate.terminate_to_shim_process
  5688                                  
  5689                                  %if 0		; old code to manually release process resources
  5690                                  	xor bx, bx		; = 0
  5691                                  	mov cx, word [32h]	; get amount of handles
  5692                                  .loop:
  5693                                  	mov ah, 3Eh
  5694                                  	int 21h			; close it
  5695                                  	inc bx			; next handle
  5696                                  	loop .loop		; loop for all process handles -->
  5697                                  %else		; new code re-using TSR terminate handling
  5698 00000F67 BA[0414]                	mov dx, .proceed
  5699 00000F6A E948FF                  	jmp qqlate.terminate_to_shim_process
  5700                                  
  5701                                  
  5702                                  	usesection lDEBUG_DATA_ENTRY
  5702          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5703                                  .proceed:
  5704 00001404 FA                      	cli
  5705 00001405 8CC8                    	mov ax, cs
  5706 00001407 8ED0                    	mov ss, ax
  5707 00001409 BC[1010]                	mov sp, stack_end
  5708 0000140C 8ED8                    	mov ds, ax
  5709 0000140E FC                      	cld
  5710 0000140F FB                      	sti
  5711                                  
  5712 00001410 E89BFF                  	call entry_to_code_seg
  5713 00001413 [6D0F]                  	dw .proceedcode
  5714                                  
  5715                                  
  5716                                  	usesection lDEBUG_CODE
  5716          ------------------       note: usesection lDEBUG_CODE
  5717                                  	code_insure_low_byte_not_0CCh
  5718                                  .proceedcode:
  5719                                  %endif
  5720                                  
  5721                                  %if _DEBUG
  5722                                  		; avoid hooking interrupts again:
  5723 00000F6D 2EC606[0000]E9          	mov byte [cs:..@patch_tsr_quit_run], __JMP_REL16
  5724                                  				; (SMC in section lDEBUG_CODE)
  5725                                  %endif
  5726 00000F73 F606[F513]01            	testopt [qq_mode], qqmode_b
  5727 00000F78 7406                    	jz @F
  5728 00000F7A C706[300E][0000]        	mov word [reg_eip], entry_int3_retf
  5729                                  @@:
  5730 00000F80 E9(0000)                	jmp run			; run this
  5731                                  
  5732                                  
  5733                                  .mode_c:
  5734                                  qqlate_device_container:
  5735 00000F83 06                      	push es
  5736 00000F84 C43E[F813]              	les di, [qq_device_prepare.device_reference]
  5737 00000F88 8CC2                    	mov dx, es		; => device header pointing to ours
  5738 00000F8A 8CD0                    	mov ax, ss		; => process segment
  5739 00000F8C 83E804                  	sub ax, deviceshim_size_p + paras(10h)
  5740                                  				; span shim and pseudo MCB
  5741                                  		; ! ax is re-used in .handlecontainer
  5742 00000F8F 8EC0                    	mov es, ax		; => our device header
  5743 00000F91 26FF360200              	push word [es:0 + 2]
  5744 00000F96 26FF360000              	push word [es:0]	; get our next link
  5745 00000F9B 8EC2                    	mov es, dx
  5746 00000F9D 268F05                  	pop word [es:di]
  5747 00000FA0 268F4502                	pop word [es:di + 2]	; update their next link
  5748 00000FA4 8EC0                    	mov es, ax
  5749 00000FA6 26830E0000FF            	or word [es:0], -1
  5750 00000FAC 26830E0200FF            	or word [es:0 + 2], -1	; de-initialise our next link
  5751 00000FB2 07                      	pop es
  5752                                  
  5753 00000FB3 31C9                    	xor cx, cx		; flag: do not shrink our allocation
  5754 00000FB5 8B1E[FC13]              	mov bx, word [qq_device_prepare.container_segment]
  5755 00000FB9 85DB                    	test bx, bx		; are we in a container ?
  5756 00000FBB 7451                    	jz .nocontainer		; no -->
  5757                                  .handlecontainer:
  5758 00000FBD 0306[920D]              	add ax, word [device_mcb_paragraphs]
  5759                                  				; => behind our allocation
  5760 00000FC1 89C2                    	mov dx, ax
  5761 00000FC3 F7DA                    	neg dx
  5762 00000FC5 0316[FE13]              	add dx, word [qq_device_prepare.container_end]
  5763                                  				; are we last in container ?
  5764 00000FC9 1E                      	push ds
  5765 00000FCA 8EDB                    	mov ds, bx		; => container
  5766                                  
  5767 00000FCC 7418                    	je .notrail		; yes, easier -->
  5768                                  
  5769 00000FCE 48                      	dec ax			; => last paragraph allocated to us
  5770                                  				;  (buffer for trailer container MCB)
  5771 00000FCF 8EC0                    	mov es, ax
  5772 00000FD1 31F6                    	xor si, si
  5773 00000FD3 31FF                    	xor di, di
  5774                                  		; copy over MCB letter, owner, and name/type
  5775 00000FD5 B90800                  	mov cx, words(16)
  5776 00000FD8 F3A5                    	rep movsw
  5777 00000FDA 36C606[0014]4D          	mov byte [ss:qq_device_prepare.container_is_z], 'M'
  5778                                  				; tell subsequent handler to use 'M'
  5779 00000FE0 2689160300              	mov word [es:3], dx	; set new size
  5780 00000FE5 41                      	inc cx			; flag: shrink our allocation
  5781                                  
  5782                                  .notrail:
  5783 00000FE6 E82B00                  	call .setowner
  5784 00000FE9 26290E0300              	sub word [es:3], cx	; -= 1 in case we have trail
  5785 00000FEE 36A0[0014]              	mov al, byte [ss:qq_device_prepare.container_is_z]
  5786 00000FF2 26A20000                	mov byte [es:0], al	; set our letter to M or Z
  5787                                  				;  (Z only if container had Z and also
  5788                                  				;  there is no trailing container created)
  5789                                  
  5790 00000FF6 29DA                    	sub dx, bx		; device mode MCB minus container MCB
  5791 00000FF8 4A                      	dec dx			; account for MCB paragraph to get MCB size
  5792 00000FF9 89160300                	mov word [3], dx	; adjust size
  5793 00000FFD C60600004D              	mov byte [0], 'M'	; set M unconditionally
  5794 00001002 85D2                    	test dx, dx		; size zero ?
  5795 00001004 7504                    	jnz @F
  5796 00001006 89160100                	mov word [1], dx	; yes, zero the owner too
  5797                                  @@:
  5798 0000100A 1F                      	pop ds
  5799 0000100B E99BFE                  	jmp qqlate.appterminate
  5800                                  
  5801                                  .nocontainer:
  5802 0000100E E80300                  	call .setowner
  5803 00001011 E995FE                  	jmp qqlate.appterminate
  5804                                  
  5805                                  
  5806                                  		; INP:	ss = debugger process/data segment
  5807                                  		; OUT:	es = dx => our device mode MCB
  5808                                  		;	owner of this MCB set to our process
  5809                                  		; STT:	R86M
  5810                                  		; CHG:	-
  5811                                  .setowner:
  5812 00001014 8CD2                    	mov dx, ss
  5813 00001016 83EA05                  	sub dx, deviceshim_size_p + paras(10h + 10h)
  5814                                  				; span shim, pseudo MCB, actual MCB
  5815 00001019 8EC2                    	mov es, dx		; => device mode MCB
  5816 0000101B 268C160100              	mov word [es:1], ss	; insure valid owner (must be our PSP)
  5817 00001020 C3                      	retn
  5818                                  %endif
  5819                                  
  5820                                  
  5821                                  %if (_APPLICATION && _TSR) || _DEVICE
  5822                                  	usesection lDEBUG_DATA_ENTRY
  5822          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5823                                  
  5824                                  qq.proceedtsrtermination:
  5825 00001415 FA                      	cli
  5826 00001416 8CC8                    	mov ax, cs
  5827 00001418 8ED0                    	mov ss, ax
  5828 0000141A BC[1010]                	mov sp, stack_end
  5829 0000141D 8ED8                    	mov ds, ax
  5830 0000141F FC                      	cld
  5831 00001420 FB                      	sti
  5832 00001421 832E[080E]12            	sub word [reg_esp], 2+4+((qq.tsrfreecode_size+1)&~1)
  5833 00001426 8B3E[080E]              	mov di, word [reg_esp]	; -> stack frame
  5834 0000142A 8E06[200E]              	mov es, word [reg_ss]
  5835 0000142E A1[180E]                	mov ax, word [reg_ds]
  5836 00001431 AB                      	stosw			; debuggee's ds
  5837 00001432 A1[300E]                	mov ax, word [reg_eip]
  5838 00001435 AB                      	stosw
  5839 00001436 A1[240E]                	mov ax, word [reg_cs]
  5840 00001439 AB                      	stosw			; debuggee's cs:ip
  5841 0000143A 06                      	push es
  5842 0000143B 57                      	push di
  5843 0000143C BE[7814]                	mov si, qq.tsrfreecode
  5844 0000143F B90600                  	mov cx, ((qq.tsrfreecode_size+1)>>1)
  5845 00001442 F3A5                    	rep movsw		; code on stack
  5846 00001444 8CC8                    	mov ax, cs		; => process segment
  5847 00001446 48                      	dec ax			; span actual MCB
  5848                                  %if _DEVICE
  5849                                   %if _APPLICATION
  5850 00001447 F606[EE01]40            	testopt [internalflags6], dif6_device_mode
  5851 0000144C 7403                    	jz @F
  5852                                   %endif
  5853 0000144E 83E804                  	sub ax, deviceshim_size_p + paras(10h)
  5854                                  				; span shim + pseudo MCB
  5855                                  @@:
  5856                                  %endif
  5857 00001451 A3[180E]                	mov word [reg_ds], ax	; = our MCB
  5858 00001454 8F06[300E]              	pop word [reg_eip]
  5859 00001458 8F06[240E]              	pop word [reg_cs]	; -> code on stack (at int3)
  5860 0000145C F606[F513]01            	testopt [qq_mode], qqmode_b
  5861                                  				; QB mode ?
  5862 00001461 7504                    	jnz @F			; yes, leave pointing cs:ip at int3
  5863 00001463 FF06[300E]              	inc word [reg_eip]	; point cs:ip past the int3
  5864                                  @@:
  5865 00001467 F606[AB01]80            	testopt [options3], opt3_tsr_quit_leave_tf
  5866 0000146C 7505                    	jnz @F
  5867 0000146E 8026[350E]FE            	clropt [reg_efl], 100h	; clear TF
  5868                                  @@:
  5869                                  
  5870 00001473 E838FF                  	call entry_to_code_seg
  5871 00001476 [2110]                  	dw .proceedtsrcode
  5872                                  
  5873                                  
  5874                                  	usesection lDEBUG_CODE
  5874          ------------------       note: usesection lDEBUG_CODE
  5875                                  
  5876                                  	code_insure_low_byte_not_0CCh
  5877                                  .proceedtsrcode:
  5878                                  %if _DEBUG
  5879                                  		; avoid hooking interrupts again:
  5880 00001021 2EC606[0000]E9          	mov byte [cs:..@patch_tsr_quit_run], __JMP_REL16
  5881                                  				; (SMC in section lDEBUG_CODE)
  5882                                  %endif
  5883 00001027 E9(0000)                	jmp run			; run this
  5884                                  
  5885                                  
  5886                                  	usesection lDEBUG_DATA_ENTRY
  5886          ------------------       note: usesection lDEBUG_DATA_ENTRY
  5887                                  
  5888                                  	align 2, db 0
  5889                                  	; (Update: Explicitly clears TF now, except if the
  5890                                  	; option opt3_tsr_quit_leave_tf is set. See above.)
  5891                                  	;
  5892                                  	; Note that since we are in control of debuggee's TF and
  5893                                  	; reset it every time the debugger is entered, this code
  5894                                  	; will not be entered with TF set. It might be entered
  5895                                  	; with IF set and an interrupt might occur; the only harm
  5896                                  	; done then is that the interrupt handler has less stack
  5897                                  	; available. All flags must be preserved by this code.
  5898                                  qq.tsrfreecode:
  5899 00001478 CC                      	int3			; breakpoint for QB mode, 1 byte
  5900 00001479 C70601000000            	mov word [1], 0		; free the MCB
  5901 0000147F 1F                      	pop ds			; restore debuggee's ds
  5902 00001480 CA0C00                  	retf ((qq.tsrfreecode_size+1)&~1)	; jump
  5903                                  qq.tsrfreecode_size: equ $-qq.tsrfreecode
  5904                                  
  5905                                  
  5906                                  	usesection lDEBUG_CODE
  5906          ------------------       note: usesection lDEBUG_CODE
  5907                                  
  5908                                  		; INP:	ax => PSP segment to set as parent
  5909                                  		;	ss:dx -> entrypoint to set as PRA
  5910                                  qqlate.setparent:
  5911 0000102A A31600                  	mov word [16h], ax
  5912 0000102D 89160A00                	mov word [0Ah], dx
  5913 00001031 8C160C00                	mov word [0Ah+2], ss
  5914 00001035 C3                      	retn
  5915                                  %endif
  5916                                  
  5917                                  
  5918                                  	usesection lDEBUG_CODE
  5918          ------------------       note: usesection lDEBUG_CODE
  5919                                  
  5920                                  %if _BOOTLDR
  5921                                  qqlate.bootterminate:
  5922 00001036 812E[080E]BE00          	sub word [reg_esp], 2*8+4+((qq.bootfreecode_size+1)&~1)
  5923 0000103C 8B3E[080E]              	mov di, word [reg_esp]	; -> stack frame
  5924 00001040 8E06[200E]              	mov es, word [reg_ss]
  5925 00001044 A1[180E]                	mov ax, word [reg_ds]
  5926 00001047 AB                      	stosw
  5927 00001048 A1[1C0E]                	mov ax, word [reg_es]
  5928 0000104B AB                      	stosw
  5929 0000104C A1[100E]                	mov ax, word [reg_esi]
  5930 0000104F AB                      	stosw
  5931 00001050 A1[140E]                	mov ax, word [reg_edi]
  5932 00001053 AB                      	stosw
  5933 00001054 A1[F80D]                	mov ax, word [reg_eax]
  5934 00001057 AB                      	stosw
  5935 00001058 A1[000E]                	mov ax, word [reg_ecx]
  5936 0000105B AB                      	stosw
  5937 0000105C A1[FC0D]                	mov ax, word [reg_ebx]
  5938 0000105F AB                      	stosw
  5939 00001060 A1[040E]                	mov ax, word [reg_edx]
  5940 00001063 AB                      	stosw
  5941 00001064 A1[300E]                	mov ax, word [reg_eip]
  5942 00001067 AB                      	stosw
  5943 00001068 A1[240E]                	mov ax, word [reg_cs]
  5944 0000106B AB                      	stosw			; debuggee's cs:ip
  5945 0000106C 06                      	push es
  5946 0000106D 57                      	push di
  5947 0000106E 1E                      	 push ds
  5948 0000106F 0E                      	  push cs
  5949 00001070 1F                      	  pop ds		; => lDEBUG_CODE
  5950 00001071 BE[EA10]                	mov si, qq.bootfreecode
  5951 00001074 B95500                  	mov cx, ((qq.bootfreecode_size+1)>>1)
  5952 00001077 F3A5                    	rep movsw		; code on stack
  5953 00001079 1F                      	 pop ds
  5954                                  
  5955 0000107A 16                      	 push ss
  5956 0000107B 07                      	 pop es
  5957                                  
  5958 0000107C A1[0000]                	mov ax, word [ boot_new_memsizekib ]
  5959 0000107F B106                    	mov cl, 6
  5960 00001081 D3E0                    	shl ax, cl		; ax => source of EBDA (new position)
  5961 00001083 8B16[0000]              	mov dx, word [ boot_old_memsizekib ]
  5962 00001087 D3E2                    	shl dx, cl		; dx => destination of EBDA (old position)
  5963 00001089 31C9                    	xor cx, cx		; size of EBDA to move (if none)
  5964 0000108B 1E                      	push ds
  5965 0000108C 8ED9                    	mov ds, cx
  5966 0000108E 8B1E0E04                	mov bx, word [40Eh]	; new ref in word [0:40Eh] (if none)
  5967 00001092 1F                      	pop ds
  5968 00001093 803E[0000]00            	cmp byte [ boot_ebdaflag ], 0	; any EBDA ?
  5969 00001098 7412                    	jz .noebda
  5970                                  
  5971 0000109A 1E                      	push ds
  5972 0000109B 8ED8                    	mov ds, ax		; => EBDA
  5973 0000109D 31DB                    	xor bx, bx
  5974 0000109F 8A1E0000                	mov bl, byte [ 0 ]	; EBDA size in KiB
  5975 000010A3 B106                    	mov cl, 6
  5976 000010A5 D3E3                    	shl bx, cl		; *64, to paragraphs
  5977 000010A7 89D9                    	mov cx, bx		; = size of EBDA to move (in paragraphs)
  5978 000010A9 89D3                    	mov bx, dx		; = new EBDA reference to put in word [0:40Eh]
  5979 000010AB 1F                      	pop ds
  5980                                  
  5981                                  .noebda:
  5982 000010AC A3[F80D]                	mov word [reg_eax], ax	; => relocated (new) EBDA position
  5983                                  				;  (in front of debugger image)
  5984 000010AF 891E[FC0D]              	mov word [reg_ebx], bx	; = what to put in word [0:40Eh],
  5985                                  				;  unchanged content of that word if no EBDA
  5986 000010B3 890E[000E]              	mov word [reg_ecx], cx	; = EBDA size, 0 if no EBDA
  5987 000010B7 8916[040E]              	mov word [reg_edx], dx	; = original (old) EBDA position
  5988                                  				; = original mem size (in paras)
  5989                                  				;  (behind/in debugger image)
  5990 000010BB C706[180E]0000          	mov word [reg_ds], 0
  5991                                  
  5992 000010C1 8F06[300E]              	pop word [reg_eip]
  5993 000010C5 8F06[240E]              	pop word [reg_cs]	; -> code on stack
  5994 000010C9 F606[F513]01            	testopt [qq_mode], qqmode_b
  5995                                  				; QB mode ?
  5996 000010CE 7504                    	jnz @F			; yes, leave pointing cs:ip at int3
  5997 000010D0 FF06[300E]              	inc word [reg_eip]	; point cs:ip past the int3
  5998                                  @@:
  5999 000010D4 F606[AB01]80            	testopt [options3], opt3_tsr_quit_leave_tf
  6000 000010D9 7505                    	jnz @F
  6001 000010DB 8026[350E]FE            	clropt [reg_efl], 100h	; clear TF
  6002                                  @@:
  6003                                  	; call dumpregs
  6004                                  %if _DEBUG
  6005                                  		; avoid hooking interrupts again:
  6006 000010E0 2EC606[0000]E9          	mov byte [cs:..@patch_tsr_quit_run], __JMP_REL16
  6007                                  				; (SMC in section lDEBUG_CODE)
  6008                                  %endif
  6009                                  	; jmp cmd3
  6010 000010E6 E9(0000)                	jmp run			; run this
  6011                                  
  6012                                  
  6013 000010E9 00                      	align 2, db 0
  6014                                  qq.bootfreecode:
  6015 000010EA CC                      	int3			; breakpoint for QB mode, 1 byte
  6016 000010EB 9C                      	pushf
  6017 000010EC FA                      	cli
  6018 000010ED E81800                  	call movp		; move EBDA back (if any)
  6019 000010F0 891E0E04                	mov word [40Eh], bx	; back relocate EBDA (if any)
  6020 000010F4 B106                    	mov cl, 6
  6021 000010F6 D3EA                    	shr dx, cl		; = to KiB
  6022 000010F8 89161304                	mov word [413h], dx	; back relocate mem size
  6023 000010FC 9D                      	popf
  6024 000010FD 1F                      	pop ds
  6025 000010FE 07                      	pop es
  6026 000010FF 5E                      	pop si
  6027 00001100 5F                      	pop di
  6028 00001101 58                      	pop ax
  6029 00001102 59                      	pop cx
  6030 00001103 5B                      	pop bx
  6031 00001104 5A                      	pop dx
  6032 00001105 CAAA00                  	retf ((qq.bootfreecode_size+1)&~1)
  6033                                  %endif
  6034                                  %endif	; !_LOADER
  6035                                  
  6036                                  
  6037                                  		; Move paragraphs
  6038                                  		;
  6039                                  		; INP:	ax:0-> source
  6040                                  		;	dx:0-> destination
  6041                                  		;	cx = number of paragraphs
  6042                                  		; CHG:	-
  6043                                  		; Note:	Doesn't work correctly on HMA; doesn't always wrap to LMA either.
  6044                                  		;	Do not provide a wrapped/HMA source or destination!
  6045                                  movp: section_of_function
  6046 00001108 51                      	push cx
  6047 00001109 1E                      	push ds
  6048 0000110A 56                      	push si
  6049 0000110B 06                      	push es
  6050 0000110C 57                      	push di
  6051                                  
  6052 0000110D 39D0                    	cmp ax, dx		; source above destination ?
  6053 0000110F 770A                    	ja .up			; yes, move up (forwards) -->
  6054 00001111 747B                    	je .return		; same, no need to move -->
  6055 00001113 50                      	push ax
  6056 00001114 01C8                    	add ax, cx		; (expected not to carry)
  6057 00001116 39D0                    	cmp ax, dx		; end of source is above destination ?
  6058 00001118 58                      	pop ax
  6059 00001119 7730                    	ja .down		; yes, move from top down -->
  6060                                  	; Here, the end of source is below-or-equal the destination,
  6061                                  	;  so they do not overlap. In this case we prefer moving up.
  6062                                  
  6063                                  .up:
  6064 0000111B 50                      	push ax
  6065 0000111C 52                      	push dx
  6066                                  .uploop:
  6067 0000111D 8ED8                    	mov ds, ax
  6068 0000111F 8EC2                    	mov es, dx
  6069 00001121 31FF                    	xor di, di
  6070 00001123 31F6                    	xor si, si		; -> start of segment
  6071 00001125 81E90010                	sub cx, 1000h		; 64 KiB left ?
  6072 00001129 7610                    	jbe .uplast		; no -->
  6073 0000112B 51                      	push cx
  6074 0000112C B90080                  	mov cx, 10000h /2
  6075 0000112F F3A5                    	rep movsw		; move 64 KiB
  6076 00001131 59                      	pop cx
  6077 00001132 050010                  	add ax, 1000h
  6078 00001135 81C20010                	add dx, 1000h		; -> next segment
  6079 00001139 EBE2                    	jmp short .uploop	; proceed for more -->
  6080                                  .uplast:
  6081 0000113B 81C10010                	add cx, 1000h		; restore counter
  6082 0000113F D1E1                    	shl cx, 1
  6083 00001141 D1E1                    	shl cx, 1
  6084 00001143 D1E1                    	shl cx, 1		; *8, paragraphs to words
  6085 00001145 F3A5                    	rep movsw		; move last part
  6086 00001147 5A                      	pop dx
  6087 00001148 58                      	pop ax
  6088 00001149 EB43                    	jmp short .return
  6089                                  
  6090                                  .down:
  6091 0000114B FD                      	std			; _AMD_ERRATUM_109_WORKAROUND as below
  6092                                  .dnloop:
  6093 0000114C 81E90010                	sub cx, 1000h		; 64 KiB left ?
  6094 00001150 761A                    	jbe .dnlast		; no -->
  6095 00001152 50                      	push ax
  6096 00001153 52                      	push dx
  6097 00001154 01C8                    	add ax, cx
  6098 00001156 01CA                    	add dx, cx
  6099 00001158 8ED8                    	mov ds, ax		; -> 64 KiB not yet moved
  6100 0000115A 8EC2                    	mov es, dx
  6101 0000115C 5A                      	pop dx
  6102 0000115D 58                      	pop ax
  6103 0000115E BFFEFF                  	mov di, -2
  6104 00001161 89FE                    	mov si, di		; moved from last word down
  6105 00001163 51                      	push cx
  6106 00001164 B90080                  	mov cx, 10000h /2
  6107 00001167 F3A5                    	rep movsw		; move 64 KiB
  6108 00001169 59                      	pop cx
  6109 0000116A EBE0                    	jmp short .dnloop	; proceed for more -->
  6110                                  .dnlast:
  6111 0000116C 81C10010                	add cx, 1000h		; restore counter
  6112 00001170 D1E1                    	shl cx, 1
  6113 00001172 D1E1                    	shl cx, 1
  6114 00001174 D1E1                    	shl cx, 1		; *8, paragraphs to words
  6115 00001176 89CF                    	mov di, cx
  6116 00001178 4F                      	dec di
  6117 00001179 D1E7                    	shl di, 1		; words to offset, -> last word
  6118 0000117B 89FE                    	mov si, di
  6119 0000117D 8ED8                    	mov ds, ax
  6120 0000117F 8EC2                    	mov es, dx		; first segment correct
  6121                                  
  6122                                  
  6123                                  	numdef AMD_ERRATUM_109_WORKAROUND, 1
  6124                                  		; Refer to comment in init.asm init_movp.
  6125                                  
  6126                                  %if _AMD_ERRATUM_109_WORKAROUND
  6127 00001181 E308                    	jcxz @FF
  6128 00001183 83F914                  	cmp cx, 20
  6129 00001186 7703                    	ja @FF
  6130                                  @@:
  6131 00001188 A5                      	movsw
  6132 00001189 E2FD                    	loop @B
  6133                                  @@:
  6134                                  %endif
  6135 0000118B F3A5                    	rep movsw		; move first part
  6136 0000118D FC                      	cld
  6137                                  .return:
  6138 0000118E 5F                      	pop di
  6139 0000118F 07                      	pop es
  6140 00001190 5E                      	pop si
  6141 00001191 1F                      	pop ds
  6142 00001192 59                      	pop cx
  6143 00001193 C3                      	retn
  6144                                  %if !_LOADER && _BOOTLDR
  6145                                  qq.bootfreecode_size: equ $-qq.bootfreecode
  6146                                  %endif
  6147                                  
  6148                                  
  6149                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT08 || _CATCHINT2D || _PM 	|| 1	; (serial)
  6153                                  		; INP:	ds:si -> IISP entry
  6154                                  		;	al = interrupt number
  6155                                  		;	dx = interrupt unhook force flag (dif4 high word)
  6156                                  		;	bx = interrupt hook status flag (dif4 low word)
  6157                                  		;	cx = letters to insert into message
  6158                                  		;	bp = number of interrupts already unable to unhook
  6159                                  		; OUT:	NC if able to unhook or not currently hooked
  6160                                  		;	CY if currently hooked and unable to unhook,
  6161                                  		;	 error message displayed
  6162                                  		;	 bp incremented
  6163                                  		; CHG:	es, dx, ah, di
  6164                                  qq_int_unhook_sim.set_bx_to_dx:
  6165 00001194 89D3                    	mov bx, dx
  6166                                  
  6167                                  qq_int_unhook_sim:
  6168 00001196 851E[E401]              	test word [internalflags4], bx
  6169 0000119A 7413                    	jz .ret			; (NC)
  6170                                  
  6171                                  .need:
  6172 0000119C E8(0000)                	call UnhookInterruptForceSim
  6173                                  				; try unhooking it
  6174 0000119F 16                      	push ss
  6175 000011A0 07                      	pop es
  6176 000011A1 730C                    	jnc .ret
  6177                                  
  6178 000011A3 890E[0000]              	mov word [msg.serial_cannot_unhook.int], cx
  6179 000011A7 BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  6180 000011AA E8(0000)                	call putsz
  6181 000011AD 45                      	inc bp
  6182 000011AE F9                      	stc
  6183                                  
  6184                                  .ret:
  6185 000011AF C3                      	retn
  6186                                  %endif
  6187                                  
  6188                                  
  6189                                  %if (_CATCHINTFAULTCOND && _CATCHINT0D) 	|| (_CATCHINTFAULTCOND && _CATCHINT0C) 	|| _CATCHINT08 || _CATCHINT2D || _PM
  6192                                  		; INP:	al = interrupt number
  6193                                  		;	ds:si -> IISP entry
  6194                                  		;	dx = interrupt unhook force flag (dif4 high word)
  6195                                  		;	bx = interrupt hook status flag (dif4 low word)
  6196                                  		;	cx = text to insert into error message
  6197                                  		; OUT:	CY if is hooked and error unhooking,
  6198                                  		;	 dx -> error message
  6199                                  		;	NC if not hooked now (already wasn't or have unhooked),
  6200                                  		;	 ZR if was already unhooked
  6201                                  		;	 NZ if has been unhooked, was hooked
  6202                                  qq_int_unhook_real.set_bx_to_dx:
  6203 000011B0 89D3                    	mov bx, dx
  6204                                  
  6205                                  qq_int_unhook_real:
  6206 000011B2 851E[E401]              	test word [internalflags4], bx
  6207 000011B6 7419                    	jz .ret			; --> (NC, ZR)
  6208                                  
  6209                                  .need:
  6210 000011B8 E8(0000)                	call UnhookInterruptForce
  6211                                  				; try unhooking it
  6212 000011BB 7309                    	jnc .unhooked
  6213                                  
  6214 000011BD 890E[0000]              	mov word [msg.serial_cannot_unhook.int], cx
  6215 000011C1 BA[0000]                	mov dx, msg.serial_cannot_unhook.nowarn
  6216 000011C4 F9                      	stc
  6217 000011C5 C3                      	retn
  6218                                  
  6219                                  .unhooked:
  6220 000011C6 F7D3                    	not bx
  6221 000011C8 211E[E401]              	and word [internalflags4], bx
  6222 000011CC E8(0000)                	call update_inttab_optional
  6223 000011CF 85E4                    	test sp, sp		; (NC, NZ)
  6224                                  .ret:
  6225 000011D1 C3                      	retn
  6226                                  %endif
  6227                                  
  6228                                  
  6229                                   %ifn _LINK || _LINK_COMPAT
  6230                                  %include "ss.asm"
  6231                                   %endif
  6232                                  
  6233                                  
  6234                                  	usesection lDEBUG_CODE
  6234          ------------------       note: usesection lDEBUG_CODE
  6235                                  
  6236                                  %if 0
  6237                                  getdebuggeebyte:
  6238                                  	push bp
  6239                                  	mov bp, sp
  6240                                  	sub sp, byte 4
  6241                                  	push bx
  6242                                  	push cx
  6243                                  %define _dedata -4
  6244                                  %define _bp 0
  6245                                  %define _ip 2
  6246                                  %define _adroffset 4
  6247                                  %define _adrsegment 8
  6248                                  	test byte [], memorydump
  6249                                  	jz .realmemory
  6250                                  
  6251                                  	jmp short .return
  6252                                  .realmemory32:
  6253                                  .realmemory:
  6254                                  	mov ax, word [ bp + _adrsegment ]
  6255                                  	mov bx, word [ bp + _adroffset ]
  6256                                  	push ds
  6257                                  	mov ds, ax
  6258                                  	push word [ bx ]
  6259                                  	pop word [ bp + _dedata ]
  6260                                  	push word [ bx +2 ]
  6261                                  	pop word [ bp + _dedata +2 ]
  6262                                  	pop ds
  6263                                  ;	test ax, ax
  6264                                  ;	jnz .return
  6265                                  	mov dx, ax
  6266                                  	mov cl, 4
  6267                                  	shl ax, cl
  6268                                  	mov cl, 12
  6269                                  	shr dx, cl
  6270                                  	add ax, bx
  6271                                  	adc dx, byte 0
  6272                                  	jnz .return
  6273                                  	sub ax, 23h*4
  6274                                  	jb .return
  6275                                  	cmp ax, 2*4
  6276                                  	jae .return
  6277                                  
  6278                                  	push ds
  6279                                  	xor bx, bx
  6280                                  	mov ds, bx
  6281                                  	push si
  6282                                  	push di
  6283                                  	mov si, 22h*4
  6284                                  	mov di, hackints.dummy22
  6285                                  	movsw
  6286                                  	movsw
  6287                                  	mov bl, 8
  6288                                  	add si, bx
  6289                                  	add di, bx
  6290                                  	movsw
  6291                                  	movsw
  6292                                  
  6293                                  	mov cl, byte [ bx - 4 + hackints2324 ]
  6294                                  	mov byte [ bp + _dedata ], cl
  6295                                  .return:
  6296                                  	pop cx
  6297                                  	pop bx
  6298                                  	pop ax
  6299                                  	pop dx
  6300                                  	pop bp
  6301                                  	retn 6
  6302                                  
  6303                                  
  6304                                  		; Interrupt hack table
  6305                                  		;
  6306                                  		; This contains the Int23 and Int24 handler we want to show
  6307                                  		; the user. As we'll retrieve a dword per access,
  6308                                  	align 4, db 0
  6309                                  hackints:
  6310                                  .dummy22:	dd 0
  6311                                  .23:		dd 0
  6312                                  .24:		dd 0
  6313                                  .dummy25:	dd 0
  6314                                  %endif
  6315                                  
  6316                                  
  6317                                   %ifn _LINK || _LINK_COMPAT
  6318                                  %if !_LOADER
  6319                                  %include "ww.asm"
  6320                                  %endif
  6321                                   %endif
  6322                                  
  6323                                  
  6324                                  	usesection lDEBUG_CODE
  6324          ------------------       note: usesection lDEBUG_CODE
  6325                                  
  6326                                  %ifn _EMS
  6327                                  xx: equ error
  6328                                  %else
  6329                                   %define extcall nearcall
  6330                                   %define extcallcall nearcall
  6331                                   %imacro internalcoderelocation 0-*.nolist
  6332                                   %endmacro
  6333                                   %imacro internaldatarelocation 0-*.nolist
  6334                                   %endmacro
  6335                                   %imacro linkdatarelocation 0-*.nolist
  6336                                   %endmacro
  6337                                   %define relocated(address) address
  6338                                   %assign ELD 0
  6339                                  
  6340                                   %include "xxshared.asm"
  6341                                  
  6342                                   %undef extcall
  6343                                   %undef extcallcall
  6344                                   %unimacro internalcoderelocation 0-*.nolist
  6345                                   %unimacro internaldatarelocation 0-*.nolist
  6346                                   %unimacro linkdatarelocation 0-*.nolist
  6347                                   %undef relocated
  6348                                  %endif	; _EMS
  6349                                  
  6350                                  %if _DUALCODE
  6351                                  	usesection lDEBUG_CODE2
  6352                                  error_mirror:
  6353                                  	dualcall error
  6354                                  
  6355                                  	usesection lDEBUG_CODE
  6356                                  %else
  6357                                  error_mirror equ error
  6358                                  %endif
  6359                                  
  6360                                  %ifn _EXPRDUALCODE && _DUALCODE
  6361                                  %if _LINK
  6362                                  error_expr: equ error
  6363                                  %endif
  6364                                  %endif
  6365                                  
  6366                                  		; Error handlers.
  6367                                  dualfunction
  6368                                  error: section_of_function
  6369 000011D2 16                      	push ss
  6370 000011D3 07                      	pop es
  6371 000011D4 16                      	push ss
  6372 000011D5 1F                      	pop ds
  6373                                  %if _RH
  6374 000011D6 8026[EE01]CF            	clropt [internalflags6], dif6_rh_mode_2 | dif6_rh_mode
  6375                                  %endif
  6376                                  
  6377                                  %if _EXTENSIONS && _EXT_PUTS_GETLINE
  6378 000011DB B304                    	mov bl, 4
  6379                                  		; INP:	bl = 4 means want to get effective carat position,
  6380                                  		;	 si -> text with error
  6381                                  		;	bl = 5 means want to get carat position with
  6382                                  		;	 si = input value for counter
  6383                                  		; OUT:	bl == 4 if to run default handling,
  6384                                  		;	 si may be modified
  6385                                  		;	bl == 5 if to use si as number of spaces to indent,
  6386                                  		;	 si = value for counter
  6387                                  		;	bl must be 4 or 5
  6388                                  		; CHG:	ax, bh, cx, dx, di
  6389                                  		; STT:	ds = es = ss
  6390                                  		;	UP, EI
  6391 000011DD E8(0000)                	call transfer_to_ext_puts_getline
  6392 000011E0 89F1                    	mov cx, si
  6393 000011E2 80FB04                  	cmp bl, 4
  6394 000011E5 7511                    	jne .gotcx
  6395                                  %else
  6396                                  	mov cx, si
  6397                                  %endif
  6398 000011E7 81E9[1300]              	sub cx, line_in+3
  6399 000011EB 81F90001                	cmp cx, 256
  6400 000011EF 7705                    	ja .invalid
  6401 000011F1 030E[AC0C]              	add cx, word [promptlen]; number of spaces to skip
  6402 000011F5 A9                      	db __TEST_IMM16		; (skip xor)
  6403                                  .invalid:
  6404 000011F6 31C9                    	xor cx, cx		; if we're really messed up
  6405                                  .gotcx:
  6406 000011F8 8B26[420C]              	mov sp, [throwsp]
  6407 000011FC FF26[400C]              	jmp near [throwret]
  6408                                  		; INP:	cx = number of spaces to indent
  6409                                  
  6410                                  		; This is the default address in throwret.
  6411                                  		; Display the error, then jump to errret.
  6412                                  errhandler:
  6413 00001200 E8(0000)                	call get_columns	; ax = columns
  6414                                  .:
  6415 00001203 29C1                    	sub cx, ax
  6416 00001205 73FC                    	jnc .
  6417 00001207 01C1                    	add cx, ax
  6418 00001209 7407                    	jz err2
  6419 0000120B B020                    	mov al, 32
  6420                                  .loop:
  6421 0000120D E8(0000)                	call putc
  6422 00001210 E2FB                    	loop .loop
  6423                                  err2:
  6424 00001212 BA[0000]                	mov dx, errcarat
  6425 00001215 E8(0000)                	call putsz		; print string
  6426 00001218 B8FF01                  	mov ax, 01FFh
  6427 0000121B E80A00                  	call setrc
  6428 0000121E C706[520D][8805]        	mov word [lastcmd], dmycmd
  6429                                  				; cancel command repetition
  6430 00001224 FF26[3E0C]              	jmp near [errret]	; return to the prompt (cmd3, aa01)
  6431                                  
  6432                                  
  6433                                  setrc: section_of_function
  6434 00001228 833E[B40C]00            	cmp word [rc], 0
  6435 0000122D 7503                    	jne .ret
  6436 0000122F A3[B40C]                	mov word [rc], ax
  6437                                  .ret:
  6438 00001232 C3                      	retn
  6439                                  
  6440                                  
  6441                                  %if !_LOADER
  6442                                  		; Terminate the attached process, if any
  6443                                  		;
  6444                                  		; OUT:	NZ if now no process attached
  6445                                  		;	ZR if still a process attached,
  6446                                  		;	 ie we failed to terminate this one
  6447                                  terminate_attached_process:
  6448 00001233 F606[DA01]80            	testopt [internalflags], attachedterm
  6449 00001238 753E                    	jnz @F
  6450                                  %if _TSR && (_APPLICATION || _DEVICE)
  6451 0000123A F606[DA01]40            	testopt [internalflags], tsrmode
  6452 0000123F 7538                    	jnz .tsr
  6453                                  %endif
  6454 00001241 8026[350E]FC            	clropt [reg_efl], 300h	; clear TF and IF
  6455 00001246 8C0E[240E]              	mov word [reg_cs], cs
  6456 0000124A C706[300E][2A0F]        	mov word [reg_eip], terminate_00
  6457 00001250 50                      	 push ax		; (dummy to take space for return address)
  6458 00001251 8C16[200E]              	mov word [reg_ss], ss
  6459 00001255 8926[080E]              	mov word [reg_esp], sp	; save current ss:sp
  6460 00001259 58                      	 pop ax			; (discard)
  6461 0000125A 31C0                    	xor ax, ax
  6462 0000125C A3[320E]                	mov word [reg_eip+2], ax
  6463 0000125F A3[0A0E]                	mov word [reg_esp+2], ax
  6464 00001262 A3[360E]                	mov word [reg_efl+2], ax
  6465                                  %if _PM
  6466                                  	mov word [reg_es], ax
  6467                                  	mov word [reg_ds], ax
  6468                                  	mov word [reg_fs], ax
  6469                                  	mov word [reg_gs], ax	; insure valid segregs in PM
  6470                                  %endif
  6471 00001265 C706[480C]8000          	mov word [run_sp_reserve], 128
  6472 0000126B E8(0000)                	call run
  6473                                  		; The dummy stack space above is to hold the return address
  6474                                  		; of this call. The debugger stack is used by this run.
  6475 0000126E 8326[480C]00            	and word [run_sp_reserve], 0
  6476                                  
  6477                                  %if _SYMBOLIC
  6478                                  	nearcall zz_detect_xms
  6479                                  	clropt [internalflags2], dif2_createdprocess
  6480                                  %endif
  6481                                  .testagain:
  6482 00001273 F606[DA01]80            	testopt [internalflags], attachedterm
  6483                                  @@:
  6484 00001278 C3                      	retn
  6485                                  
  6486                                  %if _TSR && (_APPLICATION || _DEVICE)
  6487                                  .tsr:
  6488 00001279 C706[500D][0000]        	mov word [run_int], msg.tsr_cannot_terminate_attached
  6489 0000127F EBF2                    	jmp .testagain
  6490                                  %endif
  6491                                  %endif
  6492                                  
  6493                                  
  6494                                   %ifn _LINK || _LINK_COMPAT
  6495                                  %include "vv.asm"
  6496                                   %endif
  6497                                  %if !_VXCHG && _LINK
  6498                                  vv equ error
  6499                                  %endif
  6500                                  
  6501                                  
  6502                                  %if _DEVICE && _DEVICE_SET_2324
  6503                                  	usesection lDEBUG_DATA_ENTRY
  6503          ------------------       note: usesection lDEBUG_DATA_ENTRY
  6504                                  devint23:
  6505 00001483 F9                      	stc
  6506 00001484 CB                      	retf
  6507                                  
  6508                                  devint24:
  6509 00001485 B003                    	mov al, 3
  6510 00001487 CF                      	iret
  6511                                  
  6512                                  	usesection lDEBUG_CODE
  6512          ------------------       note: usesection lDEBUG_CODE
  6513                                  %endif
  6514                                  
  6515                                  
  6516                                  ;--- this is called by "run"
  6517                                  ;--- set debuggee's INT 23/24.
  6518                                  ;--- don't use INT 21h here, DOS might be "in use".
  6519                                  ;--- registers may be modified - will soon be set to debuggee's
  6520                                  
  6521                                  %if !_LOADER
  6522                                  		; Low-level functions to reset to debuggee's interrupt vectors 23h/24h
  6523                                  		; INP:	-
  6524                                  		; OUT:	-
  6525                                  		; CHG:	bx, (e)dx, cx, ax
  6526                                  		; STT:	ds = our segment
  6527                                  		;	Do not use Int21, even if not in InDOS mode
  6528                                  setint2324:
  6529                                  %if _BOOTLDR
  6530                                   %if _APPLICATION || _DEVICE
  6531 00001281 F606[D901]40            	testopt [internalflags], nodosloaded
  6532 00001286 7514                    	jnz .ret		; don't touch int23/24 -->
  6533                                   %else
  6534                                  	retn
  6535                                   %endif
  6536                                  %endif
  6537                                  %if _APPLICATION || _DEVICE
  6538                                  %if _PM
  6539                                  	call ispm
  6540                                  	jz .pm
  6541                                  %endif
  6542 00001288 06                      	push es
  6543 00001289 57                      	push di
  6544 0000128A 56                      	push si
  6545                                  
  6546 0000128B 31FF                    	xor di, di
  6547 0000128D 8EC7                    	mov es, di
  6548 0000128F BF8C00                  	mov di, 23h *4
  6549 00001292 BE[500C]                	mov si, run2324
  6550 00001295 A5                      	movsw
  6551 00001296 A5                      	movsw
  6552 00001297 A5                      	movsw
  6553 00001298 A5                      	movsw
  6554                                  
  6555                                  %if _PM
  6556                                  	call InDOS
  6557                                  	jnz @F
  6558                                  	call hook2F
  6559                                  @@:
  6560                                  %endif
  6561 00001299 5E                      	pop si
  6562 0000129A 5F                      	pop di
  6563 0000129B 07                      	pop es
  6564                                  .ret:
  6565 0000129C C3                      	retn
  6566                                  %if _PM
  6567                                  .pm:
  6568                                  	push si
  6569                                  	mov si, run2324
  6570                                  	mov bx, 0223h
  6571                                  .loop:
  6572                                  	_386_o32		; mov edx, dword [si+0]
  6573                                  	mov dx, word [si+0]
  6574                                  	mov cx, word [si+4]
  6575                                  	mov ax, 0205h
  6576                                  	int 31h
  6577                                  	add si, 6
  6578                                  	inc bl
  6579                                  	dec bh
  6580                                  	jnz .loop
  6581                                  	pop si
  6582                                  	retn
  6583                                  %endif
  6584                                  %endif
  6585                                  
  6586                                  
  6587                                  		; Low-level functions to save debuggee's interrupt vectors 23h/24h
  6588                                  		;  and set our interrupt vectors instead
  6589                                  		; INP:	-
  6590                                  		; OUT:	-
  6591                                  		; CHG:	-
  6592                                  		; STT:	ds = our segment
  6593                                  		;	Do not use Int21, even if not in InDOS mode
  6594                                  getint2324:
  6595                                  %if _BOOTLDR
  6596                                   %if _APPLICATION || _DEVICE
  6597 0000129D F606[D901]40            	testopt [internalflags], nodosloaded
  6598 000012A2 7525                    	jnz .ret		; don't touch int23/24 -->
  6599                                   %else
  6600                                  	retn
  6601                                   %endif
  6602                                  %endif
  6603                                  %if _APPLICATION || _DEVICE
  6604                                  %if _PM
  6605                                  	call ispm
  6606                                  	jz .pm
  6607                                  %endif
  6608 000012A4 56                      	push si
  6609 000012A5 57                      	push di
  6610 000012A6 06                      	push es
  6611                                  
  6612 000012A7 1E                      	push ds
  6613 000012A8 07                      	pop es
  6614 000012A9 31FF                    	xor di, di
  6615 000012AB 8EDF                    	mov ds, di
  6616 000012AD BF[500C]                	mov di, run2324
  6617 000012B0 BE8C00                  	mov si, 23h *4
  6618 000012B3 56                      	push si
  6619 000012B4 A5                      	movsw			; save interrupt vector 23h
  6620 000012B5 A5                      	movsw
  6621 000012B6 A5                      	movsw			; save interrupt vector 24h
  6622 000012B7 A5                      	movsw
  6623 000012B8 5F                      	pop di
  6624 000012B9 06                      	push es
  6625 000012BA 1F                      	pop ds
  6626 000012BB 31F6                    	xor si, si
  6627 000012BD 8EC6                    	mov es, si
  6628 000012BF BE0E00                  	mov si, CCIV
  6629 000012C2 A5                      	movsw
  6630 000012C3 A5                      	movsw
  6631 000012C4 A5                      	movsw
  6632 000012C5 A5                      	movsw
  6633                                  
  6634 000012C6 07                      	pop es
  6635 000012C7 5F                      	pop di
  6636 000012C8 5E                      	pop si
  6637                                  .ret:
  6638 000012C9 C3                      	retn
  6639                                  %if _PM
  6640                                  subcpu 286
  6641                                  .pm:
  6642                                  	_386_o32
  6643                                  	pusha
  6644                                  	mov di, run2324
  6645                                  	mov bx, 0223h
  6646                                  .loop:
  6647                                  	mov ax, 0204h
  6648                                  	int 31h
  6649                                  	_386_o32		; mov dword [di+0], edx
  6650                                  	mov word [di+0], dx
  6651                                  	mov word [di+4], cx
  6652                                  	add di, byte 6
  6653                                  	inc bl
  6654                                  	dec bh
  6655                                  	jnz .loop
  6656                                  %if _ONLYNON386
  6657                                  	db __TEST_IMM8		; (skip pusha)
  6658                                  %else
  6659                                  	db __TEST_IMM16		; (skip pushad)
  6660                                  %endif
  6661                                  
  6662                                  restoredbgi2324:
  6663                                  setdbgi2324:
  6664                                  	_386_o32
  6665                                  	pusha
  6666                                  	mov si, dbg2324
  6667                                  	mov bx, 0223h
  6668                                  _386	xor edx, edx
  6669                                  .loop:
  6670                                  	lodsw
  6671                                  	mov dx, ax
  6672                                  	mov cx, word [cssel]
  6673                                  	mov ax, 0205h
  6674                                  	int 31h
  6675                                  	inc bl
  6676                                  	dec bh
  6677                                  	jnz .loop
  6678                                  	_386_o32
  6679                                  	popa
  6680                                  	retn
  6681                                  subcpureset
  6682                                  %endif
  6683                                  %endif
  6684                                  
  6685                                  %if 0
  6686                                  The next three subroutines concern the handling of Int23 and 24.
  6687                                  These interrupt vectors are saved and restored when running the
  6688                                  child process, but are not active when DEBUG itself is running.
  6689                                  It is still useful for the programmer to be able to check where Int23
  6690                                  and 24 point, so these values are copied into the interrupt table
  6691                                  during parts of the C, D, (DX, DI,) E, M, and S commands, so that
  6692                                  they appear to be in effect. The E command also copies these values
  6693                                  back.
  6694                                  
  6695                                  Between calls to dohack and unhack, there should be no calls to DOS,
  6696                                  so that there is no possibility of these vectors being used when
  6697                                  DEBUG itself is running.
  6698                                  
  6699                                  ; As long as no DOS is loaded anyway, Int23 and Int24 won't be touched
  6700                                  by us, so the whole hack is unnecessary and will be skipped.
  6701                                  %endif
  6702                                  
  6703                                  		; PREPHACK - Set up for interrupt vector substitution.
  6704                                  		; Entry	es = cs
  6705                                  prephack: section_of_function
  6706 000012CA 803E[640C]00            	cmp byte [hakstat], 0
  6707 000012CF 7509                    	jne .err		; if hack status error -->
  6708 000012D1 57                      	push di
  6709 000012D2 BF[5C0C]                	mov di, sav2324		; debugger's Int2324
  6710 000012D5 E80B00                  	call prehak1
  6711 000012D8 5F                      	pop di
  6712 000012D9 C3                      	retn
  6713                                  
  6714                                  .err:
  6715 000012DA 52                      	push dx
  6716 000012DB BA[0000]                	mov dx, ph_msg
  6717 000012DE E8(0000)                	call putsz		; display error
  6718 000012E1 5A                      	pop dx
  6719 000012E2 C3                      	retn
  6720                                  
  6721                                  		; INP:	di-> saved interrupt vectors
  6722                                  		; OUT:	-
  6723                                  		; CHG:	-
  6724                                  prehak1:
  6725                                  %if _PM
  6726                                  	call ispm
  6727                                  	jz .pm			; nothing to do
  6728                                  %endif
  6729 000012E3 1E                      	push ds
  6730 000012E4 56                      	push si
  6731 000012E5 31F6                    	xor si, si
  6732 000012E7 8EDE                    	mov ds, si
  6733 000012E9 BE8C00                  	mov si, 23h *4
  6734 000012EC A5                      	movsw
  6735 000012ED A5                      	movsw
  6736 000012EE A5                      	movsw
  6737 000012EF A5                      	movsw
  6738 000012F0 5E                      	pop si
  6739 000012F1 1F                      	pop ds
  6740                                  .pm:
  6741 000012F2 C3                      	retn
  6742                                  
  6743                                  
  6744                                  		; DOHACK - Fake the interrupt vectors 23h and 24h to debuggee's
  6745                                  		; UNHACK - Restore interrupt vectors 23h and 24h to our values
  6746                                  		;	It's OK to do either of these twice in a row.
  6747                                  		;	In particular, the S command may do unhack twice in a row.
  6748                                  		; INP:	ds = our segment
  6749                                  		; OUT:	es = our segment
  6750                                  		; CHG:	-
  6751                                  		; STT:	Do not use Int21
  6752                                  dohack: section_of_function
  6753 000012F3 16                      	push ss
  6754 000012F4 07                      	pop es
  6755                                  %if _BOOTLDR
  6756                                   %if _APPLICATION || _DEVICE
  6757 000012F5 F606[D901]40            	testopt [internalflags], nodosloaded
  6758 000012FA 752D                    	jnz unhack.ret		; nothing to hack -->
  6759                                   %else
  6760                                  	retn
  6761                                   %endif
  6762                                  %endif
  6763                                  %if _APPLICATION || _DEVICE
  6764 000012FC 56                      	push si
  6765 000012FD C606[640C]01            	mov byte [hakstat], 1
  6766 00001302 BE[500C]                	mov si, run2324		; debuggee's interrupt vectors
  6767                                  %if _PM
  6768                                  	call ispm
  6769                                  	jnz unhack.common
  6770                                  subcpu 286
  6771                                  	_386_o32
  6772                                  	pusha
  6773                                  	mov bx, 0223h
  6774                                  .pm_loop:
  6775                                  	_386_o32
  6776                                  	mov dx, word [si+0+0]
  6777                                  	mov cx, word [si+0+4]
  6778                                  	mov ax, 205h
  6779                                  	int 31h
  6780                                  	add si, byte 6
  6781                                  	inc bl
  6782                                  	dec bh
  6783                                  	jnz .pm_loop
  6784                                  	_386_o32
  6785                                  	popa
  6786                                  	pop si
  6787                                  	retn
  6788                                  subcpureset
  6789                                  %else
  6790 00001305 EB12                    	jmp short unhack.common
  6791                                  %endif
  6792                                  %endif
  6793                                  
  6794                                  unhack: section_of_function
  6795 00001307 16                      	push ss
  6796 00001308 07                      	pop es
  6797                                  %if _BOOTLDR
  6798                                   %if _APPLICATION || _DEVICE
  6799 00001309 F606[D901]40            	testopt [internalflags], nodosloaded
  6800 0000130E 7519                    	jnz .ret		; nothing to hack -->
  6801                                   %else
  6802                                  	retn
  6803                                   %endif
  6804                                  %endif
  6805                                  %if _APPLICATION || _DEVICE
  6806 00001310 C606[640C]00            	mov byte [hakstat], 0
  6807                                  %if _PM
  6808                                  	call ispm
  6809                                  	jz restoredbgi2324
  6810                                  %endif
  6811 00001315 56                      	push si
  6812 00001316 BE[5C0C]                	mov si, sav2324		; debugger's interrupt vectors
  6813                                  .common:
  6814 00001319 57                      	push di
  6815 0000131A 06                      	push es
  6816 0000131B 31FF                    	xor di, di
  6817 0000131D 8EC7                    	mov es, di
  6818 0000131F BF8C00                  	mov di, 23h *4
  6819 00001322 A5                      	movsw
  6820 00001323 A5                      	movsw
  6821 00001324 A5                      	movsw
  6822 00001325 A5                      	movsw
  6823 00001326 07                      	pop es
  6824 00001327 5F                      	pop di
  6825 00001328 5E                      	pop si
  6826                                  .ret:
  6827 00001329 C3                      	retn
  6828                                  %endif
  6829                                  %endif
  6830                                  
  6831                                  %if _LOADER
  6832                                  prephack: section_of_function
  6833                                  dohack: section_of_function
  6834                                  unhack: section_of_function
  6835                                  	retn
  6836                                  %endif
  6837                                  
  6838                                  
  6839                                  InDOS_or_BIOS_output:
  6840 0000132A F606[B501]02            	testopt [options6], opt6_bios_output
  6841 0000132F 7525                    	jnz InDOS.return	; if should do output to ROM-BIOS -->
  6842                                  
  6843                                  InDOS_or_BIOS_IO:
  6844 00001331 F606[B701]01            	testopt [options6], opt6_bios_io
  6845 00001336 751E                    	jnz InDOS.return	; if should do I/O from/to ROM-BIOS -->
  6846                                  
  6847                                  
  6848                                  		; OUT:	NZ if InDOS mode
  6849                                  		;	ZR if not
  6850                                  		; CHG:	-
  6851                                  		; STT:	ss = ds
  6852                                  InDOS: section_of_function
  6853                                  %if _BOOTLDR
  6854 00001338 F606[D901]40            	testopt [internalflags], nodosloaded
  6855 0000133D 7517                    	jnz .return		; always "in DOS" -->
  6856                                  %endif
  6857                                   %if _APPLICATION || _DEVICE
  6858 0000133F F606[A001]08            	testopt [options], fakeindos
  6859 00001344 7510                    	jnz .return		; faking InDOS on anyway -->
  6860                                  .real_indos:
  6861 00001346 1E                      	push ds
  6862 00001347 56                      	push si
  6863 00001348 BE[740C]                	mov si, pInDOS + so16aSegSel
  6864 0000134B E80900                  	call update_dosdata_segment
  6865 0000134E C574FE                  	lds si, [si - so16aSegSel]
  6866 00001351 803C00                  	cmp byte [si], 0
  6867 00001354 5E                      	pop si
  6868 00001355 1F                      	pop ds
  6869                                   %endif
  6870                                  .return:
  6871 00001356 C3                      	retn
  6872                                  
  6873                                  
  6874                                  		; INP:	si -> word seg or sel, word segment, word selector
  6875                                  update_dosdata_segment:
  6876                                  %if _APPLICATION || _DEVICE
  6877 00001357 F606[DF01]20            	testopt [internalflags2], dif2_int31_segment
  6878 0000135C 740D                    	jz .ret
  6879 0000135E 52                      	push dx
  6880 0000135F 50                      	push ax
  6881 00001360 53                      	push bx
  6882 00001361 B031                    	mov al, 31h
  6883 00001363 E8(0000)                	call get_86m_interrupt_handler_no_dos
  6884                                  %if _PM
  6885                                  	cmp word [si + soaSegment], dx
  6886                                  	je @F
  6887                                  
  6888                                  	call ispm
  6889                                  	jnz .realmode
  6890                                  
  6891                                  	mov bx, dx
  6892                                  	mov ax, 0002h
  6893                                  	int 31h
  6894                                  
  6895                                  	mov word [si + soaSegSel], ax
  6896                                  	mov word [si + soaSelector], ax
  6897                                  	jmp @F
  6898                                  
  6899                                  .realmode:
  6900                                  	mov word [si + soaSegSel], dx
  6901                                  	and word [si + soaSelector], 0
  6902                                  
  6903                                  @@:
  6904                                  	mov word [si + soaSegment], dx
  6905                                  	pop bx
  6906                                  	pop ax
  6907                                  %else
  6908 00001366 5B                      	pop bx
  6909 00001367 58                      	pop ax
  6910 00001368 8914                    	mov word [si + soaSegSel], dx
  6911                                  %endif
  6912 0000136A 5A                      	pop dx
  6913                                  %endif
  6914                                  .ret:
  6915 0000136B C3                      	retn
  6916                                  
  6917                                  
  6918                                  ;	PARSECM - Parse command line for C and M commands.
  6919                                  ;	Entry	AL		First nonwhite character of parameters
  6920                                  ;		SI		Address of the character after that
  6921                                  ;		DI		(If _PM) getaddr or getaddrX for second parameter
  6922                                  ;	Exit	DS:ESI		Address from first parameter
  6923                                  ;		ES:EDI		Address from second parameter
  6924                                  ;		ECX		Length of address range minus one
  6925                                  ;		[bAddr32]	Set if any high word non-zero
  6926                                  
  6927                                  parsecm_have_address:
  6928 0000136C E8(0000)                	nearcall getrangeX_have_address_need_length
  6929 0000136F EB0C                    	jmp @F
  6930                                  
  6931                                  parsecm:
  6932 00001371 E856FF                  	call prephack
  6933 00001374 8B1E[180E]              	mov bx, word [reg_ds]	; get source range
  6934 00001378 31C9                    	xor cx, cx
  6935 0000137A E8(0000)                	nearcall getrangeX	; get address range into bx:(e)dx bx:(e)cx
  6936                                  		; Bug fixed in Debug/X 2.00: This used the same scratch
  6937                                  		;  selector as the getaddr used for the second operand.
  6938                                  		; As we never write to the first operand of an C or M
  6939                                  		;  command the simple fix is to use getrangeX here.
  6940                                  @@:
  6941 0000137D 53                      	push bx			; save segment first address
  6942 0000137E E8(0000)                	call skipcomm0
  6943 00001381 8B1E[180E]              	mov bx, word [reg_ds]
  6944                                  	_386_PM_o32	; sub ecx, edx
  6945 00001385 29D1                    	sub cx, dx		; number of bytes minus one
  6946                                  	_386_PM_o32	; push edx
  6947 00001387 52                      	push dx
  6948                                  	_386_PM_o32	; push ecx
  6949 00001388 51                      	push cx
  6950                                  %if _PM
  6951                                  	mov cl, byte [bAddr32]
  6952                                  	push cx
  6953                                  %if _DUALCODE && _EXPRDUALCODE
  6954                                  	nearcall ..@parsecm_getaddr
  6955                                  
  6956                                  	usesection lDEBUG_CODE2
  6957                                  ..@parsecm_getaddr: section_of_function
  6958                                  	jmp di
  6959                                  
  6960                                  	usesection lDEBUG_CODE
  6961                                  %else
  6962                                  	call di			; get destination address into bx:edx
  6963                                  %endif
  6964                                  	pop cx
  6965                                  	or byte [bAddr32], cl	; if either is 32-bit, handle both as 32-bit
  6966                                  %else
  6967 00001389 E8(0000)                	nearcall getaddr	; get destination address into bx:dx
  6968                                  %endif
  6969                                  	_386_PM_o32
  6970 0000138C 59                      	pop cx		; pop ecx
  6971                                  	_386_PM_o32	; mov edi, edx
  6972 0000138D 89D7                    	mov di, dx
  6973                                  	_386_PM_o32
  6974 0000138F 01CA                    	add dx, cx	; add edx, ecx
  6975 00001391 7208                    	jc short errorj7	; if it wrapped around
  6976 00001393 E8(0000)                	call chkeol		; expect end of line
  6977 00001396 8EC3                    	mov es, bx
  6978                                  	_386_PM_o32	; pop esi
  6979 00001398 5E                      	pop si
  6980 00001399 1F                      	pop ds
  6981 0000139A C3                      	retn
  6982                                  
  6983                                  errorj7:
  6984 0000139B E934FE                  	jmp error
  6985                                  
  6986                                  
  6987                                  %if _APPLICATION || _DEVICE
  6988                                  ;	PARSELW - Parse command line for L and W commands.
  6989                                  ;
  6990                                  ;	Entry	AL	First nonwhite character of parameters
  6991                                  ;		SI	Address of the character after that
  6992                                  ;
  6993                                  ;	Exit	If there is at most one argument (program load/write), then the
  6994                                  ;		zero flag is set, and registers are set as follows:
  6995                                  ;		bx:(e)dx	Transfer address
  6996                                  ;
  6997                                  ;		If there are more arguments (absolute disk read/write), then the
  6998                                  ;		zero flag is clear, and registers are set as follows:
  6999                                  ;
  7000                                  ;		DOS versions prior to 3.31:
  7001                                  ;		AL	Drive number
  7002                                  ;		CX	Number of sectors to read
  7003                                  ;		DX	Beginning logical sector number
  7004                                  ;		DS:BX	Transfer address
  7005                                  ;
  7006                                  ;		Later DOS versions:
  7007                                  ;		AL	Drive number
  7008                                  ;		BX	Offset of packet
  7009                                  ;		CX	0FFFFh
  7010                                  
  7011                                  	usesection lDEBUG_DATA_ENTRY
  7011          ------------------       note: usesection lDEBUG_DATA_ENTRY
  7012                                  	align 4, db 0
  7013 00001488 00000000                packet:	dd 0		; sector number
  7014 0000148C 0000                    	dw 0		; number of sectors to read
  7015 0000148E 00000000                	dd 0		; transfer address Segm:OOOO
  7016                                  %if _PM
  7017                                  	dw 0		; transfer address might be Segm:OOOOOOOO!
  7018                                  %endif
  7019                                  
  7020                                  	usesection lDEBUG_CODE
  7020          ------------------       note: usesection lDEBUG_CODE
  7021                                  parselw:
  7022 0000139E 8B1E[240E]              	mov bx, word [reg_cs]	; default segment
  7023 000013A2 66                      	_386_o32	; xor edx, edx
  7024 000013A3 31D2                    	xor dx, dx
  7025 000013A5 F606[580D]08            	test byte [fileext], EXT_HEX
  7026 000013AA 7502                    	jnz @F			; if .HEX file, default offset is 0 -->
  7027 000013AC B601                    	mov dh, 1		; default offset in dx = 100h
  7028                                  @@:
  7029 000013AE E8(0000)                	call iseol?
  7030 000013B1 7468                    	je plw2			; if no arguments
  7031 000013B3 E8(0000)                	nearcall getaddr	; get buffer address into bx:(e)dx
  7032 000013B6 E8(0000)                	call skipcomm0
  7033 000013B9 E8(0000)                	call iseol?
  7034 000013BC 745D                    	je plw2			; if only one argument
  7035 000013BE 53                      	push bx			; save segment
  7036 000013BF 52                      	push dx			; save offset
  7037 000013C0 BB8000                  	mov bx, 80h		; max number of sectors to read
  7038 000013C3 F7DA                    	neg dx
  7039 000013C5 7406                    	jz plw1			; if address is zero
  7040 000013C7 B109                    	mov cl, 9
  7041 000013C9 D3EA                    	shr dx, cl		; max number of sectors which can be read
  7042 000013CB 89D7                    	mov di, dx
  7043                                  plw1:
  7044 000013CD 803C3A                  	cmp byte [si], ':'	; drive letter specification ?
  7045 000013D0 750F                    	jne @F			; no -->
  7046                                  
  7047 000013D2 50                      	push ax
  7048 000013D3 E8(0000)                	call capitalise
  7049 000013D6 2C41                    	sub al, 'A'
  7050 000013D8 3C20                    	cmp al, 32		; valid drive ?
  7051 000013DA 88C2                    	mov dl, al		; put drive number
  7052 000013DC 46                      	inc si			; -> past the colon
  7053 000013DD 58                      	pop ax
  7054 000013DE 7205                    	jb @FF			; got it -->
  7055 000013E0 4E                      	dec si			; -> at colon
  7056                                  
  7057                                  @@:
  7058 000013E1 E8(0000)                	nearcall getbyte	; get drive number (DL)
  7059 000013E4 A8                      	db __TEST_IMM8		; (skip lodsb)
  7060                                  @@:
  7061 000013E5 AC                      	lodsb
  7062 000013E6 E8(0000)                	call skipcomm0
  7063 000013E9 52                      	push dx
  7064 000013EA 80C241                  	add dl, 'A'
  7065 000013ED 8816[0000]              	mov byte [driveno], dl
  7066 000013F1 E8(0000)                	nearcall getdword	; get relative sector number
  7067 000013F4 E8(0000)                	call skipcomm0
  7068 000013F7 53                      	push bx			; save sector number high
  7069 000013F8 52                      	push dx			; save sector number low
  7070 000013F9 56                      	push si			; in case we find an error
  7071 000013FA E8(0000)                	nearcall getword	; get sector count
  7072 000013FD 4A                      	dec dx
  7073 000013FE 39FA                    	cmp dx, di
  7074 00001400 7399                    	jae errorj7		; if too many sectors
  7075 00001402 42                      	inc dx
  7076 00001403 89D1                    	mov cx, dx
  7077 00001405 E8(0000)                	call chkeol		; expect end of line
  7078 00001408 F606[D801]07            	testopt [internalflags], oldpacket| newpacket| ntpacket
  7079 0000140D 750D                    	jnz plw3		; if using a packet -->
  7080 0000140F 5E                      	pop si			; in case of error
  7081 00001410 5A                      	pop dx			; get LoWord starting logical sector number
  7082 00001411 5B                      	pop bx			; get HiWord
  7083 00001412 85DB                    	test bx, bx		; just a 16-bit sector number possible
  7084 00001414 7585                    	jnz errorj7		; if too big
  7085 00001416 58                      	pop ax			; drive number
  7086 00001417 5B                      	pop bx			; transfer buffer ofs
  7087 00001418 1F                      	pop ds			; transfer buffer seg
  7088 00001419 85C9                    	test cx, cx		; NZ
  7089                                  plw2:
  7090 0000141B C3                      	retn
  7091                                  
  7092                                  		; disk I/O packet for Int25/Int26, Int21.7305, VDD
  7093                                  plw3:
  7094 0000141C 5B                      	pop bx			; discard si
  7095 0000141D BB[8814]                	mov bx, packet
  7096 00001420 8F07                    	pop word [bx+0]		; LoWord sector number
  7097 00001422 8F4702                  	pop word [bx+2]		; HiWord sector number
  7098 00001425 894F04                  	mov word [bx+4], cx	; number of sectors
  7099 00001428 58                      	pop ax			; drive number
  7100 00001429 8F4706                  	pop word [bx+6]		; transfer address ofs
  7101 0000142C 5A                      	pop dx
  7102 0000142D 31C9                    	xor cx, cx
  7103                                  %if _PM
  7104                                  	call ispm
  7105                                  	jnz plw3_1
  7106                                  	cmp byte [dpmi32], 0
  7107                                  	jz plw3_1
  7108                                  [cpu 386]
  7109                                  	mov word [bx+10], dx	; save segment of transfer buffer
  7110                                  	movzx ebx, bx
  7111                                  	shr edx, 16		; get HiWord(offset)
  7112                                  	cmp byte [bAddr32], 1
  7113                                  	jz plw3_1
  7114                                  	xor dx, dx
  7115                                  __CPU__
  7116                                  plw3_1:
  7117                                  %endif
  7118 0000142F 895708                  	mov word [bx+8], dx	; transfer address seg
  7119 00001432 49                      	dec cx			; NZ and make cx = -1
  7120 00001433 C3                      	retn
  7121                                  %endif
  7122                                  
  7123                                  
  7124                                   %ifn _LINK || _LINK_COMPAT
  7125                                  %include "expr.asm"
  7126                                  %include "rr.asm"
  7127                                  
  7128                                  
  7129                                  %include "lineio.asm"
  7130                                  
  7131                                  
  7132                                  %include "ints.asm"
  7133                                   %endif
  7134                                  %if !_40COLUMNS && _LINK
  7135                                  puts_break_line_more: equ dmycmd
  7136                                  %endif
  7137                                  
  7138                                  
  7139                                  	usesection lDEBUG_CODE
  7139          ------------------       note: usesection lDEBUG_CODE
  7140                                  
  7141                                  %if _BOOTLDR
  7142                                  		; Determine the amount of actual memory
  7143                                  		;
  7144                                  		; This is important to call at the time we need the size,
  7145                                  		; not just save the size initially. Loading other pre-boot
  7146                                  		; installers or RPLs will change the size.
  7147                                  		;
  7148                                  		; INP:	-
  7149                                  		; OUT:	dx = segment behind usable memory (taking EBDAs & RPLs into account)
  7150                                  		;	ds = ss
  7151                                  		; CHG:	ax, cx, di, si, ds
  7152                                  bootgetmemorysize: section_of_function
  7153 00001434 06                      	push es
  7154 00001435 31C0                    	xor ax, ax
  7155 00001437 8ED8                    	mov ds, ax
  7156 00001439 CD12                    	int 12h					; get memory size in KiB
  7157 0000143B B106                    	mov cl, 6
  7158 0000143D D3E0                    	shl ax, cl				; *64, convert to paragraphs
  7159 0000143F 50                      	push ax
  7160 00001440 C536BC00                	lds si, [ 2Fh *4 ]			; get current Int2F
  7161 00001444 46                      	inc si					; pointer valid (not 0FFFFh) ? (left increased!)
  7162 00001445 741B                    	jz .norpl				; no -->
  7163 00001447 8CD8                    	mov ax, ds
  7164 00001449 85C0                    	test ax, ax				; segment valid (not zero) ?
  7165 0000144B 7415                    	jz .norpl				; no -->
  7166 0000144D 46<rep 2h>              	times 2 inc si				; +3 with above inc
  7167 0000144F 0E                      	push cs
  7168 00001450 07                      	pop es
  7169 00001451 BF[6714]                	mov di, .rpl
  7170 00001454 B90300                  	mov cx, .rpl_size
  7171 00001457 F3A6                    	repe cmpsb				; "RPL" signature ?
  7172 00001459 7507                    	jne .norpl				; no -->
  7173 0000145B 5A                      	pop dx
  7174 0000145C B8064A                  	mov ax, 4A06h
  7175 0000145F CD2F                    	int 2Fh					; adjust usable memory size for RPL
  7176 00001461 A8                      	db __TEST_IMM8				; (skip pop)
  7177                                  .norpl:
  7178 00001462 5A                      	pop dx
  7179                                  		; dx = segment behind last available memory
  7180 00001463 16                      	 push ss
  7181 00001464 1F                      	 pop ds
  7182 00001465 07                      	pop es
  7183 00001466 C3                      	retn
  7184                                  
  7185 00001467 52504C                  .rpl:	db "RPL"
  7186                                  	endarea .rpl
  7187                                  %endif
  7188                                  
  7189                                  
  7190                                  %if !_LOADER
  7191                                  		; Ensure a debuggee process is loaded
  7192                                  		;
  7193                                  		; INP:	si:di = to preserve if have a process already
  7194                                  		; OUT:	NZ if have no process and unable to create process
  7195                                  		;	ZR if have a process or created empty process
  7196                                  		;	NC if had no process yet, created one or not
  7197                                  		;	CY if had a process already,
  7198                                  		;	 si:di = preserved input
  7199                                  		;	NC, ZR if had no process, created empty one,
  7200                                  		;	 si:di = debuggee cs:ip
  7201                                  		;	NC, NZ if int19 occurred (or bootloaded)
  7202                                  		; CHG:	si, di, cx
  7203                                  ensuredebuggeeloaded:
  7204 0000146A 50                      	push ax
  7205 0000146B 53                      	push bx
  7206 0000146C 52                      	push dx
  7207                                  
  7208 0000146D F606[E201]20            	testopt [internalflags3], dif3_gotint19
  7209 00001472 746F                    	jz .notint19
  7210                                  
  7211 00001474 8026[E201]DF            	clropt [internalflags3], dif3_gotint19
  7212                                  %if _BOOTLDR
  7213                                   %if _APPLICATION || _DEVICE
  7214 00001479 F606[D901]40            	testopt [internalflags], nodosloaded
  7215 0000147E 743B                    	jz .dosint19
  7216                                   %endif
  7217                                  
  7218                                  .bootint19:
  7219 00001480 E86E01                  	call zeroregs
  7220                                  
  7221 00001483 B86000                  	mov ax, 60h
  7222 00001486 50                      	push ax
  7223 00001487 BF[180E]                	mov di, reg_ds
  7224 0000148A AB                      	stosw
  7225 0000148B AF                      	scasw			; (skip dummy high word)
  7226 0000148C AB                      	stosw
  7227 0000148D AF                      	scasw
  7228 0000148E AB                      	stosw
  7229 0000148F AF                      	scasw
  7230 00001490 AB                      	stosw
  7231 00001491 E8(0000)                	call adusetup
  7232 00001494 E89DFF                  	call bootgetmemorysize
  7233 00001497 83EA60                  	sub dx, 60h
  7234 0000149A 81FA0010                	cmp dx, 1000h
  7235 0000149E 7602                    	jbe .bootbelow64kib	; if memory left <= 64 KiB
  7236 000014A0 31D2                    	xor dx, dx		; dx = 1000h (same thing, after shifting)
  7237                                  .bootbelow64kib:
  7238 000014A2 B104                    	mov cl, 4
  7239 000014A4 D3E2                    	shl dx, cl
  7240 000014A6 4A                      	dec dx
  7241 000014A7 4A                      	dec dx
  7242 000014A8 8916[080E]              	mov word [reg_esp], dx
  7243 000014AC 07                      	pop es
  7244 000014AD 87D7                    	xchg dx, di		; es:di = child stack pointer
  7245 000014AF 31C0                    	xor ax, ax
  7246 000014B1 AB                      	stosw			; push 0 on client's stack
  7247                                  
  7248 000014B2 26C7060000CD19          	mov word [es:0], 019CDh	; place opcode for int 19h at cs:ip
  7249 000014B9 EB1B                    	jmp @F
  7250                                  %endif
  7251                                  
  7252                                   %if _APPLICATION || _DEVICE
  7253                                  .dosint19:
  7254 000014BB 8B16[080E]              	mov dx, word [reg_esp]
  7255 000014BF 8B1E[200E]              	mov bx, word [reg_ss]
  7256                                  
  7257 000014C3 E82B01                  	call zeroregs
  7258                                  
  7259                                  		; Upon receiving an int 19h in DOS
  7260                                  		;  just set up some shim that will
  7261                                  		;  lead to process termination.
  7262                                  		; Unlike before we do not longer try
  7263                                  		;  to create a new process then.
  7264 000014C6 8916[080E]              	mov word [reg_esp], dx
  7265 000014CA 891E[200E]              	mov word [reg_ss], bx	; preserve our stack
  7266 000014CE FF36[4C0C]              	push word [pspdbe]
  7267 000014D2 8F06[240E]              	pop word [reg_cs]	; cs = PSP, ip = 0,
  7268                                  				;  cs:ip -> int 20h instruction
  7269                                  
  7270                                  @@:
  7271 000014D6 F606[DA01]80            	testopt [internalflags], attachedterm
  7272 000014DB 7511                    	jnz .noprocess		; if also process not loaded
  7273                                  
  7274 000014DD 80CA01                  	or dl, 1		; flags return NC, NZ
  7275 000014E0 E9FE00                  	jmp .return
  7276                                   %endif
  7277                                  
  7278                                  .notint19:
  7279 000014E3 F606[DA01]80            	testopt [internalflags], attachedterm
  7280 000014E8 7504                    	jnz .noprocess		; not loaded, create -->
  7281                                  				; flags return ZR
  7282 000014EA F9                      	stc			; flags return CY
  7283 000014EB E9F300                  	jmp .return
  7284                                  
  7285                                  .noprocess:
  7286                                  %if _BOOTLDR
  7287                                   %if _APPLICATION || _DEVICE
  7288 000014EE F606[D901]40            	testopt [internalflags], nodosloaded
  7289 000014F3 7403E9E900              	jnz .return		; flags return NC, NZ
  7290                                   %else
  7291                                  	jmp .return
  7292                                   %endif
  7293                                  %endif
  7294                                  
  7295                                   %if _APPLICATION || _DEVICE
  7296                                  .dosnoprocess:
  7297 000014F8 B448                    	mov ah, 48h		; get size of largest free block
  7298 000014FA BBFFFF                  	mov bx, -1
  7299 000014FD CD21                    	int 21h
  7300 000014FF 83FB20                  	cmp bx, 20h		; enough for PSP + 256 Bytes for code/stack ?
  7301 00001502 7303E9E000              	jb .return_no_clr	; no -->
  7302 00001507 B448                    	mov ah, 48h		; allocate it
  7303 00001509 CD21                    	int 21h
  7304 0000150B 7303E9D700              	jc .return_no_clr	; (memory taken between the calls)
  7305                                  
  7306 00001510 50                      	push ax
  7307 00001511 E8DD00                  	call zeroregs
  7308 00001514 C606[310E]01            	mov byte [reg_eip+1], 100h>>8
  7309 00001519 58                      	pop ax
  7310                                  
  7311 0000151A 53                      	push bx
  7312                                  %if _SYMBOLIC
  7313                                  	push bx
  7314                                  %endif
  7315 0000151B BF[180E]                	mov di, reg_ds		; fill segment registers ds,es,ss,cs
  7316 0000151E AB                      	stosw
  7317 0000151F AF                      	scasw			; (skip dummy high word)
  7318 00001520 AB                      	stosw
  7319 00001521 AF                      	scasw
  7320 00001522 AB                      	stosw
  7321 00001523 AF                      	scasw
  7322 00001524 AB                      	stosw
  7323 00001525 E8(0000)                	call adusetup
  7324 00001528 8B1E[240E]              	mov bx, word [reg_cs]	; bx:dx = where to load program
  7325 0000152C 8EC3                    	mov es, bx
  7326 0000152E 58                      	pop ax			; get size of memory block
  7327 0000152F 89C2                    	mov dx, ax
  7328 00001531 01DA                    	add dx, bx
  7329 00001533 2689160200              	mov word [es:ALASAP], dx
  7330 00001538 50                      	push ax
  7331 00001539 3D0010                  	cmp ax, 1000h
  7332 0000153C 7602                    	jbe .below64kib		; if memory left <= 64 KiB
  7333 0000153E 31C0                    	xor ax, ax		; ax = 1000h (same thing, after shifting)
  7334                                  .below64kib:
  7335 00001540 B104                    	mov cl, 4
  7336 00001542 D3E0                    	shl ax, cl
  7337 00001544 48                      	dec ax
  7338 00001545 48                      	dec ax
  7339 00001546 A3[080E]                	mov word [reg_esp], ax
  7340 00001549 97                      	xchg ax, di		; es:di = child stack pointer
  7341 0000154A 31C0                    	xor ax, ax
  7342 0000154C AB                      	stosw			; push 0 on client's stack
  7343                                  
  7344                                  		; Create a PSP
  7345 0000154D B455                    	mov ah, 55h		; create child PSP
  7346 0000154F 8CC2                    	mov dx, es
  7347 00001551 268B360200              	mov si, word [es:ALASAP]
  7348 00001556 F8                      	clc			; works around OS/2 bug
  7349 00001557 CD21                    	int 21h
  7350 00001559 2689360200              	mov word [es:ALASAP], si
  7351 0000155E E8D4F2                  	call setpspdbg		; reset PSP to ours
  7352 00001561 E8(0000)                	call ll_copy_cmdline_and_fcbs
  7353 00001564 58                      	pop ax
  7354                                  
  7355 00001565 1E                      	push ds
  7356 00001566 06                      	 push es
  7357 00001567 1F                      	 pop ds
  7358 00001568 3DFF0F                  	cmp ax, 0FFFh
  7359 0000156B 7603                    	jbe @F
  7360 0000156D B8FF0F                  	mov ax, 0FFFh		; 0FFFh for large blocks
  7361                                  @@:
  7362 00001570 83E810                  	sub ax, 10h		; cannot underflow because block is >= 110h Bytes
  7363                                  				; at most 0FEFh
  7364 00001573 BB0C00                  	mov bx, 0Ch
  7365 00001576 29C3                    	sub bx, ax		; 000Ch - 00FEFh = 0F01Dh
  7366 00001578 B104                    	mov cl, 4
  7367 0000157A D3E0                    	shl ax, cl		; 0FEF0h
  7368                                  		; call far 0F01Dh:0FEF0h = 1000C0h
  7369                                  		; This is either the same as 0C0h if A20 masked, or in the HMA.
  7370 0000157C C60605009A              	mov byte [CPMCALL], 09Ah; call far imm:imm opcode
  7371 00001581 A30600                  	mov word [CPMCALL + 1], ax
  7372 00001584 891E0800                	mov word [CPMCALL + 3], bx	; adjusted CALL 5 dispatcher
  7373                                  
  7374 00001588 BA8000                  	mov dx, 80h
  7375 0000158B B41A                    	mov ah, 1Ah		; set DTA to default DTA
  7376 0000158D CD21                    	int 21h
  7377 0000158F 1F                      	pop ds
  7378                                  
  7379                                  		; Finish up. Set termination address.
  7380 00001590 B82225                  	mov ax, 2522h		; set interrupt vector 22h
  7381 00001593 BA[0000]                	mov dx, int22
  7382 00001596 CD21                    	int 21h
  7383 00001598 2689160A00              	mov word [es:TPIV], dx
  7384 0000159D 268C1E0C00              	mov word [es:TPIV+2], ds
  7385                                  
  7386 000015A2 26C6060001C3            	mov byte [es:100h], 0C3h	; place opcode for retn at cs:ip
  7387                                  
  7388                                  %if _SYMBOLIC
  7389                                  	pop bx				; size of memory block
  7390                                  %endif
  7391 000015A8 8C06[4C0C]              	mov word [pspdbe], es
  7392 000015AC 8CC0                    	mov ax, es
  7393 000015AE 48                      	dec ax
  7394 000015AF 8EC0                    	mov es, ax
  7395 000015B1 40                      	inc ax
  7396 000015B2 26C70608004445          	mov word [es:8+0], "DE"
  7397 000015B9 26C7060A004255          	mov word [es:8+2], "BU"
  7398 000015C0 26C7060C004747          	mov word [es:8+4], "GG"
  7399 000015C7 26C7060E004545          	mov word [es:8+6], "EE"	; set MCB name
  7400 000015CE 26A30100                	mov word [es:1], ax	; set MCB owner
  7401                                  
  7402                                  %if _SYMBOLIC
  7403                                  	setopt [internalflags2], dif2_createdprocess
  7404                                  	mov word [created_psp], ax
  7405                                  	mov word [created_size], bx
  7406                                  %endif
  7407                                  
  7408 000015D2 8B36[240E]              	mov si, word [reg_cs]
  7409 000015D6 8B3E[300E]              	mov di, word [reg_eip]		; ? is this ever used ?
  7410                                  
  7411 000015DA 8026[DA01]7F            	clropt [internalflags], attachedterm
  7412 000015DF 38C0                    	cmp al, al			; flags return ZR, NC
  7413                                   %endif
  7414                                  
  7415                                  .return:
  7416                                  @@:
  7417 000015E1 16                      	push ss
  7418 000015E2 07                      	pop es
  7419                                  
  7420 000015E3 5A                      	pop dx
  7421 000015E4 5B                      	pop bx
  7422 000015E5 58                      	pop ax
  7423 000015E6 C3                      	retn
  7424                                  
  7425                                  .return_no_clr:
  7426 000015E7 BA[0000]                	mov dx, msg.ensure_no_memory
  7427 000015EA E8(0000)                	call putsz
  7428 000015ED 85D2                    	test dx, dx			; flags return NZ, NC
  7429 000015EF EBF0                    	jmp .return
  7430                                  %endif
  7431                                  
  7432                                  
  7433                                  zeroregs:
  7434                                  	; call set_efl_to_fl	; initialise EFL, and ax = 0
  7435                                  ; set_efl_to_fl:
  7436 000015F1 31C0                    	xor ax, ax		; initialise ax = 0 and FL = ZR NC etc
  7437 000015F3 50                      _no386	push ax			; dummy high word
  7438 000015F4 66                      	_386_o32	; pushfd
  7439 000015F5 9C                      	pushf
  7440 000015F6 8F06[340E]              	pop word [reg_efl]	; set to FL
  7441 000015FA 8F06[360E]              	pop word [reg_efl+2]	; set to high word of EFL, or zero
  7442                                  	; retn
  7443                                  
  7444 000015FE BF[F80D]                	mov di, regs
  7445 00001601 B91E00                  	mov cx, 15 * 2		; (8 standard + 6 segregs + eip) * 2
  7446 00001604 F3AB                    	rep stosw		; initialise all registers
  7447 00001606 C3                      	retn
  7448                                  
  7449                                  
  7450                                  %if _PM
  7451                                  		; Hook Int2F if a DPMI host is found. However for Win9x and DosEmu
  7452                                  		; Int2F.1687 is not hooked because it doesn't work. Debugging in
  7453                                  		; protected mode may still work, but the initial switch must be
  7454                                  		; single-stepped.
  7455                                  		;
  7456                                  		; CHG:	ah, bx, cx, dx, di, es
  7457                                  		; OUT:	al = 0FFh if installed
  7458                                  		;	al = status value 0F0h..0FEh else
  7459                                  		; STT:	V86/RM
  7460                                  		;	ds = debugger data segment
  7461                                  		;	! might be called with unknown ss
  7462                                  		;	  if [internalflags6] & dif6_in_amis_hook2F
  7463                                  hook2F:
  7464                                  	call InDOS
  7465                                  	mov al, 0FEh
  7466                                  	jnz .return
  7467                                  %if _APPLICATION || _DEVICE
  7468                                  .not_in_dos:
  7469                                  	mov al, 0FDh
  7470                                  	testopt [internalflags], hooked2F
  7471                                  	jnz .return		; don't hook now -->
  7472                                  	dec ax			; 0FCh
  7473                                   %if _DEBUG
  7474                                  	testopt [internalflags6], dif6_in_hook2F
  7475                                  	jnz .return
  7476                                   %endif
  7477                                  .loop:
  7478                                   %if _GUARD_86M_INT2F
  7479                                  	push es
  7480                                  	xor ax, ax
  7481                                  	mov es, ax		; (only used in 86 Mode)
  7482                                  	mov ax, [es:2Fh * 4]
  7483                                  	cmp ax, -1
  7484                                  	je @F			; --> (ZR)
  7485                                  	or ax, [es:2Fh * 4 + 2]
  7486                                  @@:
  7487                                  	pop es
  7488                                  	mov al, 0FBh
  7489                                  	jz .return
  7490                                   %endif
  7491                                   %if _DEBUG
  7492                                  	testopt [internalflags6], dif6_in_amis_hook2F
  7493                                  	jnz @F
  7494                                  	push si
  7495                                  	call findinstalleddebugger
  7496                                  				; CHG: si, di, es, ax, cx, dx
  7497                                  	pop si
  7498                                  	jc @F
  7499                                  	setopt [internalflags6], dif6_in_hook2F
  7500                                  				; avoid recursion
  7501                                  	inc ax			; al = 31h
  7502                                  	int 2Dh			; call out to debugger
  7503                                  	clropt [internalflags6], dif6_in_hook2F
  7504                                  	cmp al, 0FFh
  7505                                  	jne @F
  7506                                    %if _DISPHOOK
  7507                                  	mov dx, dpmihookamis
  7508                                  	call putsz
  7509                                    %endif
  7510                                  @@:
  7511                                   %endif
  7512                                  	mov ax, 1687h		; DPMI host installed?
  7513                                  	int 2Fh
  7514                                  	test ax, ax
  7515                                  	mov al, 0FAh
  7516                                  	jnz .return
  7517                                  	mov word [dpmientry+0], di	; true host DPMI entry
  7518                                  	mov word [dpmientry+2], es
  7519                                  	mov word [dpmiwatch+0], di
  7520                                  	mov word [dpmiwatch+2], es
  7521                                  	dec ax			; 0F9h
  7522                                  		; Previously checked DIF nohook2F here.
  7523                                  	dec ax			; 0F8h
  7524                                  	testopt [options4], opt4_int_2F_hook
  7525                                  	jz .return		; requested to not hook -->
  7526                                  	mov ax, 352Fh
  7527                                  	int 21h
  7528                                  	mov word [oldi2F+0], bx
  7529                                  	mov word [oldi2F+2], es
  7530                                  	mov dx, debug2F		; ds => lDEBUG_DATA_ENTRY
  7531                                  	mov ax, 252Fh
  7532                                  	int 21h
  7533                                  
  7534                                  		; Test whether we can hook the DPMI entrypoint call.
  7535                                  	mov ax, 1687h
  7536                                  	int 2Fh
  7537                                  	test ax, ax
  7538                                  	jnz .nohost
  7539                                  	cmp di, mydpmientry	; our entrypoint returned ?
  7540                                  	jne .nohook
  7541                                  	mov ax, es
  7542                                  	mov bx, ds		; bx => lDEBUG_DATA_ENTRY
  7543                                  	cmp ax, bx
  7544                                  	jne .nohook		; no -->
  7545                                  
  7546                                  	mov word [dpmiwatch+0], mydpmientry
  7547                                  	mov word [dpmiwatch+2], ds	; => lDEBUG_DATA_ENTRY
  7548                                  
  7549                                  	setopt [internalflags], hooked2F
  7550                                  	setopt [internalflags4], dif4_int_2F_hooked
  7551                                  	call update_inttab_optional
  7552                                  %if _DISPHOOK
  7553                                  	testopt [internalflags6], dif6_in_amis_hook2F
  7554                                  	jnz @F
  7555                                  	mov ax, ds		; ax => lDEBUG_DATA_ENTRY
  7556                                  	push ds
  7557                                  	pop es
  7558                                  	mov di, dpmihookcs
  7559                                  	call hexword
  7560                                  	mov dx, dpmihook
  7561                                  	call putsz
  7562                                  @@:
  7563                                  %endif
  7564                                  	mov al, 0FFh
  7565                                  %endif
  7566                                  .return:
  7567                                  	push ds
  7568                                  	pop es
  7569                                  	retn
  7570                                  
  7571                                  %if _APPLICATION || _DEVICE
  7572                                  .nohost:
  7573                                  .nohook:
  7574                                  	push ds
  7575                                  	lds dx, [oldi2F]
  7576                                  	mov ax, 252Fh
  7577                                  	int 21h			; unhook
  7578                                  	pop ds
  7579                                  	push ds
  7580                                  	pop es			; restore segregs
  7581                                  	clropt [options4], opt4_int_2F_hook
  7582                                  				; disable hook next
  7583                                  	testopt [internalflags6], dif6_in_amis_hook2F
  7584                                  	jnz @F
  7585                                  	mov dx, msg.dpmi_no_hook
  7586                                  	call putsz		; display message about it
  7587                                  @@:
  7588                                  	call .loop
  7589                                  	mov al, 0F0h
  7590                                  	retn
  7591                                  %endif
  7592                                  %endif
  7593                                  
  7594                                  
  7595                                  		; Following bits need to be *before* boot.asm
  7596                                  		;  to support the _BOOTLDR_DISCARD option.
  7597                                  		;  But boot.asm must be included before init.asm
  7598                                  		;  so that init will get the nearcall/dualcall
  7599                                  		;  uses in boot.asm in its relocation tables.
  7600                                  		; So all code section contents originally from
  7601                                  		;  init.asm is now moved to here.
  7602                                  %if _SYMBOLIC && (_APPLICATION || _DEVICE)
  7603                                  		; Moved this here so the nearcall macro is used
  7604                                  		;  before we write the relocate_from_code table.
  7605                                  	usesection lDEBUG_CODE
  7606                                  ..@switch_s_cont:
  7607                                  	nearcall zz_save_strat
  7608                                  	nearcall zz_switch_s
  7609                                  	dec si
  7610                                  	mov dx, si
  7611                                  	retf
  7612                                  
  7613                                  ..@switch_s_catch:
  7614                                  	mov sp, word [throwsp]	; restore stack
  7615                                  				;  (needed here if returned to errret)
  7616                                  	mov dx, errcarat
  7617                                  	call putsz
  7618                                  	xor dx, dx
  7619                                  	retf
  7620                                  %endif
  7621                                  
  7622                                  
  7623                                  	usesection lDEBUG_CODE
  7623          ------------------       note: usesection lDEBUG_CODE
  7624                                  initcont:
  7625                                  %if _APPLICATION
  7626 00001607 CD21                    	int 21h				; resize to required
  7627                                  ;	jc ...				; (expected to work since it had to be larger. also we hooked ints)
  7628                                  %endif
  7629                                  
  7630                                  %if _APPLICATION || _DEVICE
  7631                                  .device:
  7632                                  %if _VXCHG
  7633 00001609 E8(0000)                	call vv_set
  7634                                  %endif
  7635                                  
  7636 0000160C 1E                      	push ds
  7637 0000160D 07                      	pop es
  7638 0000160E E88CFC                  	call getint2324			; init run2324 to avoid using or displaying NUL vectors
  7639                                  
  7640 00001611 1E                      	push ds
  7641 00001612 07                      	pop es
  7642 00001613 5E                      	pop si
  7643 00001614 AC                      	lodsb
  7644 00001615 E8ADF2                  	call kk				; process the rest of the command line
  7645                                  %endif
  7646                                  
  7647                                  .boot_entry:
  7648 00001618 1E                      	push ds
  7649 00001619 07                      	pop es				; => lDEBUG_DATA_ENTRY
  7650                                  
  7651                                  %if _ALTVID
  7652                                  ;	mov al, ALTSCREENBITS
  7653 0000161A E8(0000)                	call setscreen
  7654                                  %endif
  7655                                  
  7656 0000161D BE[0000]                	mov si, cmd3
  7657                                  %if _BOOTLDR
  7658                                   %if _APPLICATION || _DEVICE
  7659 00001620 F606[D901]40            	testopt [internalflags], nodosloaded
  7660 00001625 7402                    	jz @F
  7661                                   %endif
  7662                                   %if _LOADER
  7663                                  	push si
  7664                                  	jmp moveloader_hook_ints
  7665                                   %else
  7666 00001627 FFE6                    	jmp si				; directly jump to cmd3 of the installed image
  7667                                   %endif
  7668                                  @@:
  7669                                  %endif
  7670                                  %if _APPLICATION || _DEVICE
  7671 00001629 56                      	push si
  7672 0000162A E9(0000)                	jmp ll3				; load a program if one has been given at the command line
  7673                                  %endif
  7674                                  
  7675                                  
  7676                                   %if !_LINK && _LINK_COMPAT
  7677                                  	usesection lDEBUG_CODE
  7678                                  %if !_LOADER
  7679                                  %include "aa.asm"
  7680                                  %endif
  7681                                  
  7682                                  	usesection lDEBUG_CODE
  7683                                  %include "amis.asm"
  7684                                  
  7685                                  	usesection lDEBUG_CODE
  7686                                  %include "bb.asm"
  7687                                  
  7688                                  %if !_LOADER
  7689                                  	usesection lDEBUG_CODE
  7690                                  %include "cc.asm"
  7691                                  %endif
  7692                                  
  7693                                  	usesection lDEBUG_CODE
  7694                                  %include "dd.asm"
  7695                                  
  7696                                  	usesection lDEBUG_CODE
  7697                                  %include "ee.asm"
  7698                                  
  7699                                  	usesection lDEBUG_CODE
  7700                                  %include "expr.asm"
  7701                                  
  7702                                  	usesection lDEBUG_CODE
  7703                                  %include "ff.asm"
  7704                                  
  7705                                  %if _RN
  7706                                   %imacro internaldatarelocation 0-*.nolist
  7707                                   %endmacro
  7708                                  	usesection lDEBUG_CODE
  7709                                   %include "fptostr.asm"
  7710                                   %unimacro internaldatarelocation 0-*.nolist
  7711                                  %endif
  7712                                  %if _HELP_COMPRESSED
  7713                                  	overridedef STANDALONE, 0
  7714                                  	usesection lDEBUG_CODE
  7715                                  %include "helpdepk.asm"
  7716                                  	resetdef STANDALONE
  7717                                  %endif
  7718                                  
  7719                                  	usesection lDEBUG_CODE
  7720                                  %include "hh.asm"
  7721                                  
  7722                                  	usesection lDEBUG_CODE
  7723                                  %include "iioo.asm"
  7724                                  
  7725                                  %if _IMMASM
  7726                                  	usesection lDEBUG_CODE
  7727                                  %include "immasm.asm"
  7728                                  %else
  7729                                  	usesection lDEBUG_CODE
  7730                                  immasm:
  7731                                  	lodsb
  7732                                  	call chkeol
  7733                                  	jmp cmd3
  7734                                  %endif
  7735                                  
  7736                                  	usesection lDEBUG_CODE
  7737                                  %include "install.asm"
  7738                                  
  7739                                  	usesection lDEBUG_CODE
  7740                                  %include "ints.asm"
  7741                                  
  7742                                  	usesection lDEBUG_CODE
  7743                                  %include "lineio.asm"
  7744                                  
  7745                                  %if !_LOADER
  7746                                  	usesection lDEBUG_CODE
  7747                                  %include "ll.asm"
  7748                                  %endif
  7749                                  
  7750                                  	usesection lDEBUG_CODE
  7751                                  %include "mm.asm"
  7752                                  
  7753                                  	usesection lDEBUG_DATA_ENTRY
  7754                                  msg_start:
  7755                                  	%include "msg.asm"
  7756                                  msg_end:
  7757                                  
  7758                                  	numdef SHOWMSGSIZE, _DEFAULTSHOWSIZE
  7759                                  %if _SHOWMSGSIZE
  7760                                  %assign MSGSIZE msg_end - msg_start
  7761                                  %warning msg holds MSGSIZE bytes
  7762                                  %endif
  7763                                  
  7764                                  %if _PM
  7765                                  	usesection lDEBUG_CODE
  7766                                  %include "pmdata.asm"
  7767                                  
  7768                                  	usesection lDEBUG_CODE
  7769                                  %include "pmentry.asm"
  7770                                  
  7771                                  	usesection lDEBUG_CODE
  7772                                  %include "pminit.asm"
  7773                                  %endif
  7774                                  
  7775                                  	usesection lDEBUG_CODE
  7776                                  %include "rr.asm"
  7777                                  
  7778                                  	usesection lDEBUG_CODE
  7779                                  %include "run.asm"
  7780                                  
  7781                                  	usesection lDEBUG_CODE
  7782                                  %include "serialp.asm"
  7783                                  
  7784                                  	usesection lDEBUG_CODE
  7785                                  %include "ss.asm"
  7786                                  
  7787                                  %if _SYMBOLIC
  7788                                  	usesection lDEBUG_CODE
  7789                                  %include "symbols.asm"
  7790                                  %endif
  7791                                  
  7792                                  	usesection lDEBUG_CODE
  7793                                  %include "uu.asm"
  7794                                  
  7795                                  	usesection lDEBUG_CODE
  7796                                  %include "vv.asm"
  7797                                  
  7798                                  %if !_LOADER
  7799                                  	usesection lDEBUG_CODE
  7800                                  %include "ww.asm"
  7801                                  %endif
  7802                                  
  7803                                   %endif
  7804                                  
  7805                                   %ifn _LINK
  7806                                  %if _BOOTLDR_DISCARD
  7807                                  	usesection lDEBUG_CODE
  7808                                  ldebug_code_bootldr_truncated_size: equ fromparas(paras($ - code_start))
  7809                                  %else
  7810                                  ldebug_code_bootldr_truncated_size: equ ldebug_code_size
  7811                                  %endif
  7812                                  	endarea ldebug_code_bootldr_truncated, 1
  7813                                  
  7814                                  %if _BOOTLDR
  7815                                   %include "boot.asm"
  7816                                  %endif
  7817                                   %endif
  7818                                  
  7819                                  
  7820                                  %if _LINK
  7821                                  [list -]
  7894                                  	usesection DATASTACKBASE
  7894          ------------------       note: usesection DATASTACKBASE
  7895                                  	absolute $
  7896                                   %endif
  7897                                  
  7898                                  %if !_LOADER
  7899                                  	alignb 4
  7900 00000000 ????                    bp_offset:	resw 1
  7901                                  %if _PM
  7902                                  		resw 1
  7903                                  %endif
  7904                                  %endif
  7905                                  
  7906                                  %if _BREAKPOINTS
  7907 00000002 ????                    	alignb 4
  7908 00000004 ????????                ..@bb_saved_linear:	resd 1
  7909                                  
  7910                                  	alignb 4
  7911 00000008 ????                    ..@bb_id_start:		resw 1
  7912 0000000A ????                    ..@bb_id_length:	resw 1
  7913 0000000C ????                    ..@bb_when_start:	resw 1
  7914 0000000E ????                    ..@bb_when_length:	resw 1
  7915                                  %endif
  7916                                  
  7917                                  		; I/O buffers
  7918                                  	alignb 2
  7919 00000010 ??                      line_in:	resb 1			; maximal length of input line
  7920 00000011 ??                      		resb 1			; actual length (must be one less than previous byte)
  7921 00000012 <res FFh>               		resb 255		; buffer for 13-terminated input line
  7922                                  .end:
  7923                                  
  7924                                  %if _CONFIG
  7925 00000111 ??                      	alignb 2
  7926 00000112 <res 180h>              configpath:	resb 128 + 256
  7927 00000292 ????                    .dir_end:	resw 1
  7928                                  
  7929                                  	alignb 2
  7930 00000294 <res 180h>              scriptspath:	resb 128 + 256
  7931 00000414 ????                    .dir_end:	resw 1
  7932                                  
  7933                                  yy_try_scriptspath:
  7934 00000416 ??                      .nokeywordused:	resb 1
  7935 00000417 ??                      .didnotyettry:	resb 1
  7936                                  %endif
  7937                                   %if _EXTENSIONS
  7938                                  	alignb 2
  7939 00000418 ????                    ext_cmdline:	resw 1
  7940                                    %if _ELDTRAILER
  7941 0000041A ????????                eldheader:	resd 1
  7942                                    %endif
  7943                                   %endif
  7944                                   %if _EXTENSIONS || _INPUT_FILE_HANDLES || _INPUT_FILE_BOOT
  7945 0000041E ??                      yy_is_script:	resb 1			; else extension
  7946                                   %endif
  7947                                  
  7948                                  	; zero-initialisation starts here
  7949                                  ..@init_first:
  7950 0000041F ??                      		resb 1			; line_in overflow stop
  7951                                  			; This byte is zero-initialised. When line_in
  7952                                  			;  is scanned using skipcomma (in bb.asm) but
  7953                                  			;  al already had the CR, then the scan may
  7954                                  			;  overflow line_in. Including this byte here
  7955                                  			;  (_after_ line_in) insures that the scan will
  7956                                  			;  stop while still reading within the section.
  7957                                  				; b_bplist and g_bplist are expected in that order by initcont
  7958                                  %if _BREAKPOINTS
  7959                                  	alignb 2
  7960                                  b_bplist:
  7961 00000420 ????                    .used_mask:	resb (_NUM_B_BP + _NUM_SYM_BP + 7) >> 3
  7962                                  					; bitmask of used points
  7963 00000422 ????                    .disabled_mask:	resb (_NUM_B_BP + _NUM_SYM_BP + 7) >> 3
  7964                                  					; bitmask of disabled points
  7965                                   %if _BREAKPOINTS_STICKY
  7966                                  .sticky_mask:	resb (_NUM_B_BP + _NUM_SYM_BP + 7) >> 3
  7967                                  					; bitmask of sticky points
  7968                                  					; desc: stay around during DEBUG's operation unless
  7969                                  					; explicitly removed/un-stickified. This allows
  7970                                  					; to keep breakpoints around while changing from PM.
  7971                                  					; Hits while in DEBUG are ignored though, use DDEBUG.
  7972                                  					; Disabling won't remove them, just ignores hits.
  7973                                   %endif
  7974                                  	alignb 2
  7975 00000424 <res 60h>               .bp:		resb (_NUM_B_BP + _NUM_SYM_BP) * BPSIZE
  7976                                  	alignb 2
  7977 00000484 <res 20h>               .counter:	resw _NUM_B_BP
  7978                                  	alignb 2
  7979 000004A4 <res 20h>               .id:		resw _NUM_B_BP		; array of lengths/offsets, 0 = unused
  7980                                  			; low 10 bits = offset into .idbuffer (0..1023)
  7981                                  			; high 6 bits = length (0..63, 0 if unused)
  7982                                  	alignb 2
  7983 000004C4 <res 20h>               .when:		resw _NUM_B_BP		; array of pointers, 0 = unused
  7984                                  .idbuffer.free:
  7985 000004E4 ????                    		resw 1			; offset into .idbuffer of free space
  7986                                  					; (0..1024)
  7987                                  .whenbuffer.free:
  7988 000004E6 ????                    		resw 1			; *offset* into .whenbuffer
  7989                                  					;  (not a pointer)
  7990                                  .idbuffer:
  7991 000004E8 <res 180h>              		resb _NUM_B_ID_BYTES	; buffer holding ID strings
  7992                                  .whenbuffer:
  7993 00000668 <res 400h>              		resb _NUM_B_WHEN_BYTES	; buffer holding condition strings
  7994                                  %endif
  7995                                  %if _NUM_G_BP
  7996 00000A68 ??                      	resb 1 - (($-$$) % 2)		; make g_bplist.bp aligned
  7997                                  g_bplist:
  7998 00000A69 ??                      .used_count:	resb 1			; for the byte counter of saved breakpoints
  7999 00000A6A <res 60h>               .bp:		resb _NUM_G_BP*BPSIZE
  8000                                  .end:
  8001                                  %endif
  8002                                  %if !_LOADER
  8003 00000ACA ??                      sss_silent_count_used:	resb 1
  8004 00000ACB ??                      drivenumber:		resb 1
  8005                                  %if _MCBPOSITION
  8006                                  mcbposition:		resb 1
  8007                                  %endif
  8008                                  %if _SDSUB
  8009                                  skipsd:			resb 1
  8010                                  %endif
  8011                                  %if _MCBLIMIT
  8012                                  	alignb 2
  8013                                  mcblimit:		resw 1
  8014                                  %endif
  8015                                  %endif
  8016                                  %if _HISTORY && ! _HISTORY_SEPARATE_FIXED
  8017                                  	alignb 2
  8018                                  historybuffer:	resb _HISTORY_SIZE
  8019                                  .end:
  8020                                  %endif
  8021                                  
  8022                                  		; $ - $$	= offset into section
  8023                                  		; % 2		= 1 if odd offset, 0 if even
  8024                                  		; 2 -		= 1 if odd, 2 if even
  8025                                  		; % 2		= 1 if odd, 0 if even
  8026                                  	; resb (2 - (($-$$) % 2)) % 2
  8027                                  		; $ - $$	= offset into section
  8028                                  		; % 2		= 1 if odd offset, 0 if even
  8029                                  		; 1 -		= 0 if odd, 1 if even
  8030 00000ACC ??                      	resb 1 - (($-$$) % 2)		; make line_out aligned
  8031 00000ACD ??                      trim_overflow:	resb 1			; actually part of line_out to avoid overflow of trimputs loop
  8032 00000ACE <res 107h>              line_out:	resb 263
  8033 00000BD5 ??                      		resb 1			; reserved for terminating zero
  8034                                  line_out_end:
  8035                                  	alignb 2
  8036 00000BD6 ????                    line_out_overflow:	resw 1		; 2642h if line_out didn't overflow
  8037                                  
  8038                                  %if !_LOADER
  8039                                  	alignb 4
  8040 00000BD8 ????????                sss_silent_count:	resd 1
  8041                                  %endif
  8042                                  	alignb 2
  8043 00000BDC ????                    getrange_lines:		resw 1
  8044                                  
  8045 00000BDE ????                    serial_save_irq_mask:	resw 1
  8046 00000BE0 ????                    serial_save_irq_off:	resw 1
  8047 00000BE2 ????                    serial_save_dl:		resw 1
  8048 00000BE4 ??                      serial_save_ier:	resb 1
  8049 00000BE5 ??                      serial_save_lcr:	resb 1
  8050 00000BE6 ??                      serial_save_mcr:	resb 1
  8051                                  %if _USE_TX_FIFO
  8052 00000BE7 ??                       serial_fcr_setting:	resb 1
  8053                                  %endif
  8054 00000BE8 ??                      serial_use_intnum:	resb 1
  8055 00000BE9 ??                      serial_use_params:	resb 1
  8056 00000BEA ??                      serial_use_fifo:	resb 1
  8057                                  %if _RH
  8058 00000BEB ??                      rh_display_with_count:	resb 1
  8059                                  	alignb 2
  8060 00000BEC ????                    rh_count_number:	resw 1
  8061                                  %endif
  8062                                  	alignb 2
  8063                                  baseport:
  8064 00000BEE ????                    serial_use_baseport:	resw 1
  8065 00000BF0 ????                    serial_use_dl:		resw 1
  8066 00000BF2 ????                    serial_use_irqmask:	resw 1
  8067                                  
  8068                                  	alignb 2
  8069 00000BF4 ????                    rxhead:		resw 1
  8070 00000BF6 ????                    rxtail:		resw 1
  8071 00000BF8 ????                    txhead:		resw 1
  8072 00000BFA ????                    txtail:		resw 1
  8073 00000BFC ????????                	alignb 16
  8074 00000C00 <res 80h>               rxfifo:		resb _RXFIFOSIZE
  8075                                  	alignb 16
  8076 00000C80 <res 80h>               txfifo:		resb _TXFIFOSIZE
  8077                                  
  8078                                   %if _SYMBOLIC
  8079                                  %if _BUFFER_86MM_SLICE || _XMS_SYMBOL_TABLE
  8080                                  	alignb 16
  8081                                  access_slice_buffer:
  8082                                  .:
  8083                                  	resb ssString + 255
  8084                                  	alignb 2
  8085                                  .size:	equ $ - .
  8086                                   %if _SECOND_SLICE
  8087                                  	alignb 16
  8088                                  second_access_slice_buffer:
  8089                                  .:
  8090                                  	resb ssString + 255
  8091                                  	alignb 2
  8092                                  .size:	equ $ - .
  8093                                   %endif
  8094                                  %endif
  8095                                   %endif
  8096                                  
  8097                                  	alignb 2
  8098                                  while_buffer:
  8099                                  .length equ _WHILEBUFFSIZE
  8100 00000D00 <res 108h>              	resb .length
  8101                                  .end:
  8102                                  
  8103                                  %if (_MMXSUPP && _RM && ! _RM_AUX) || (_RN && ! _RN_AUX)
  8104                                  	alignb 4
  8105                                  rn_rm_buffer:
  8106                                   %if (_RN && ! _RN_AUX)
  8107                                  		resb 128
  8108                                   %else
  8109                                  		resb 108
  8110                                   %endif
  8111                                  %endif
  8112                                  
  8113                                  %if _SYMBOLIC
  8114                                  	alignb 16
  8115                                  str_buffer:	resb 512		; long enough for smName1 + smName2 content
  8116                                  		; by placing this buffer below the stack, a stack overflow
  8117                                  		;  might be less harmful if the str_buffer isn't in use.
  8118                                  %endif
  8119                                  
  8120                                  	; zero-initialisation ends here
  8121                                  ..@init_behind:
  8122                                  
  8123 00000E08 ????????????????        		alignb 16		; stack might be re-used as GDT, so align it on a paragraph
  8124 00000E10 <res 200h>              stack:		resb _STACKSIZE
  8125                                  		alignb 2		; ensure stack aligned
  8126                                  stack_end:
  8127                                  
  8128                                  %if _EXTENSIONS
  8129                                  	alignb 16
  8130                                  ext_data_area:
  8131 00001010 <res 4000h>             .:	resb _EXT_DATA_BOOT_SIZE
  8132                                  	alignb 16
  8133                                  .size equ $ - .
  8134                                  
  8135                                    %ifn _LINK
  8136                                  ext_data_max_size_equate equ 0FFF0h - (ext_data_area + SECTIONFIXUP)
  8137                                   %if ((_EXT_DATA_BOOT_SIZE + 15) & ~15) <= ((_EXT_DATA_INIT_SIZE + 15) & ~15)
  8138                                    ext_data_nonboot_add_size equ ((_EXT_DATA_INIT_SIZE + 15) & ~15) - ((_EXT_DATA_BOOT_SIZE + 15) & ~15)
  8139                                   %else
  8140                                    ext_data_nonboot_add_size equ 0
  8141                                   %endif
  8142                                    %endif
  8143                                  %else
  8144                                    %ifn _LINK
  8145                                   ext_data_max_size_equate equ 0
  8146                                   ext_data_nonboot_add_size equ 0
  8147                                    %endif
  8148                                  %endif
  8149                                  
  8150                                  %if _LINK
  8151                                   global end_of_datastack
  8152                                  %endif
  8153                                  	alignb 16
  8154                                  end_of_datastack:
  8155                                  
  8156                                    %ifn _LINK
  8157                                  datastack_size	equ $-section.DATASTACK.vstart
  8158                                  	endarea datastack, 1
  8159                                  
  8160                                  
  8161                                  auxbuff_size: equ (_AUXBUFFSIZE+15) & ~15
  8162                                  	endarea auxbuff, 1
  8163                                  
  8164                                  auxbuff_max_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  8165                                  	endarea auxbuff_max, 1
  8166                                  
  8167                                  %if _INIT_MAX
  8168                                   auxbuff_init_size: equ (_AUXBUFFMAXSIZE+15) & ~15
  8169                                  %else
  8170                                   auxbuff_init_size: equ (_AUXBUFFSIZE+15) & ~15
  8171                                  %endif
  8172                                  	endarea auxbuff_init, 1
  8173                                  
  8174                                  
  8175                                  pspsegment_size:	equ 100h + DATAENTRYTABLESIZE + datastack_size
  8176                                  	endarea pspsegment, 1			; size of PSP and image when installed
  8177                                  
  8178                                  
  8179                                  	numdef SHOWASMTABLESIZE, _DEFAULTSHOWSIZE
  8180                                  %if _SHOWASMTABLESIZE
  8181                                  %assign ASMTABLESIZE asmtable1_size + asmtable2_size
  8182                                  %warning asmtables hold ASMTABLESIZE bytes
  8183                                  %endif
  8184                                  
  8185                                  
  8186                                  %assign __INITSIZE init_size
  8187                                  %if __INITSIZE > (64 * 1024)
  8188                                   %error init segment too large (%[__INITSIZE])
  8189                                  %endif
  8190                                  
  8191                                  	numdef SHOWINITSIZE, _DEFAULTSHOWSIZE
  8192                                  %if _SHOWINITSIZE
  8193                                  %warning init segment holds __INITSIZE bytes
  8194                                  %endif
  8195                                  
  8196                                  
  8197                                  %assign __CODESIZE ldebug_code_size
  8198                                  %if __CODESIZE > (64 * 1024)
  8199                                   %error code segment too large (%[__CODESIZE])
  8200                                  %endif
  8201                                  
  8202                                  	numdef SHOWCODESIZE, _DEFAULTSHOWSIZE
  8203                                  %if _SHOWCODESIZE
  8204                                  %warning code segment holds __CODESIZE bytes
  8205                                  %endif
  8206                                  
  8207                                  
  8208                                  %assign __CODETRUNCATEDSIZE ldebug_code_bootldr_truncated_size
  8209                                  %assign __CODEDISCARDSIZE ldebug_code_size - ldebug_code_bootldr_truncated_size
  8210                                  
  8211                                  %if _BOOTLDR_DISCARD
  8212                                  	numdef SHOWCODETRUNCATEDSIZE, _DEFAULTSHOWSIZE
  8213                                  %else
  8214                                  	numdef SHOWCODETRUNCATEDSIZE, 0
  8215                                  %endif
  8216                                  %if _SHOWCODETRUNCATEDSIZE
  8217                                  %warning code segment truncated holds __CODETRUNCATEDSIZE bytes (__CODEDISCARDSIZE bytes discarded)
  8218                                  %endif
  8219                                  
  8220                                  
  8221                                  %assign __CODE2SIZE ldebug_code2_size
  8222                                  %if __CODE2SIZE > (64 * 1024)
  8223                                   %error code segment 2 too large (%[__CODE2SIZE])
  8224                                  %endif
  8225                                  
  8226                                  %if _DUALCODE
  8227                                  	numdef SHOWCODE2SIZE, _DEFAULTSHOWSIZE
  8228                                  %else
  8229                                  	numdef SHOWCODE2SIZE, 0
  8230                                  %endif
  8231                                  %if _SHOWCODE2SIZE
  8232                                  %warning code segment 2 holds __CODE2SIZE bytes
  8233                                  %endif
  8234                                  
  8235                                  
  8236                                  %assign __MESSAGESEGMENTSIZE messagesegment_nobits_size
  8237                                  %if __MESSAGESEGMENTSIZE > (64 * 1024)
  8238                                   %error message segment too large (%[__MESSAGESEGMENTSIZE])
  8239                                  %endif
  8240                                  
  8241                                  %if _MESSAGESEGMENT
  8242                                  	numdef SHOWMESSAGESEGMENTSIZE, _DEFAULTSHOWSIZE
  8243                                  %else
  8244                                  	numdef SHOWMESSAGESEGMENTSIZE, 0
  8245                                  %endif
  8246                                  %if _SHOWMESSAGESEGMENTSIZE
  8247                                  %warning message segment holds __MESSAGESEGMENTSIZE bytes
  8248                                  %endif
  8249                                  
  8250                                  
  8251                                  %assign __MESSAGESEGMENTTRUNCATEDSIZE messagesegment_nobits_truncated_size
  8252                                  %assign __MESSAGESEGMENTDISCARDSIZE messagesegment_nobits_size - messagesegment_nobits_truncated_size
  8253                                  
  8254                                  %if _BOOTLDR_DISCARD_HELP
  8255                                  	numdef SHOWMESSAGESEGMENTTRUNCATEDSIZE, _DEFAULTSHOWSIZE
  8256                                  %else
  8257                                  	numdef SHOWMESSAGESEGMENTTRUNCATEDSIZE, 0
  8258                                  %endif
  8259                                  %if _SHOWMESSAGESEGMENTTRUNCATEDSIZE
  8260                                  %warning message segment truncated holds __MESSAGESEGMENTTRUNCATEDSIZE bytes (__MESSAGESEGMENTDISCARDSIZE bytes discarded)
  8261                                  %endif
  8262                                  
  8263                                  
  8264                                  %assign __PSPSEGMENTSIZE pspsegment_size
  8265                                  %assign __PSPSEGMENTMAXSIZE pspsegment_size - _EXT_DATA_BOOT_SIZE + ext_data_max_size_equate
  8266                                  %if __PSPSEGMENTSIZE > (64 * 1024)
  8267                                   %error resident size of PSP segment too large (%[__PSPSEGMENTSIZE])
  8268                                  %elif __PSPSEGMENTMAXSIZE > (64 * 1024 - 16)
  8269                                   %error resident maximum size of PSP segment too large (%[__PSPSEGMENTMAXSIZE])
  8270                                  %endif
  8271                                  
  8272                                  	numdef SHOWPSPSIZE, _DEFAULTSHOWSIZE
  8273                                  %if _SHOWPSPSIZE
  8274                                  %warning PSP segment holds __PSPSEGMENTSIZE bytes
  8275                                   %if _EXTENSIONS
  8276                                    %warning Maximum PSP segment holds __PSPSEGMENTMAXSIZE bytes
  8277                                   %endif
  8278                                  %endif
  8279                                  
  8280                                  %if CODE_INSURE_COUNT
  8281                                   %warning code_insure_low_byte_not_0CCh needed CODE_INSURE_COUNT times
  8282                                  %endif
  8283                                    %endif
