Repository navigation
fix: INT 21h AH=0Ch waits for a key typed after the flush - #2488
Conversation
INT 21h AH=0Ch flushed the input, then called the C# handler of the function in AL directly. That skipped the stub's STDIN wait loop. With the console as STDIN and no key pending, AL=01h, 07h, 08h and 0Ah returned NUL at once instead of waiting for a key. For those four functions the AH=0Ch handler now moves CS:IP to the stub's existing STDIN wait loop instead of running them. The loop's dispatch callback, now DispatchStdinInput, runs the function in AL once STDIN is ready, without flushing again. AL=06h still runs at once, and AH stays 0Ch. The stub bytes do not change. Golden changes: the dispatch callback's generated comment now names DispatchStdinInput instead of the generic INT 21h description in the 187 generated programs that contain the stub. flush_input_then_read_ah01 now goes through the wait loop: its generated code checks where the callback moved CS:IP, and the loop is no longer speculative. Its RegisterReads bound goes from 12 to 16 for that check (CS and IP, read in the condition and in the failure message), and its Statements bound from 151 to 149. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rh22PkoQR3deb3SC5uZvxL
There was a problem hiding this comment.
🟡 Changes recommended
AX=0C01h waits indefinitely when redirected STDIN is empty or at EOF because the readiness check prevents the reader from returning its EOF result.
1 open issue
What changed in this PR
Reviewed only commit a631d03c, excluding the six inherited commits from #2482. It routes INT 21h AH=0Ch blocking input functions through the existing STDIN wait loop without changing BIOS stub bytes or addresses.
Changes:
- Flush input once, then dispatch the selected input function after STDIN becomes ready.
- Add
flush_input_then_wait_key_ah01, which checks that AX=0C01h returns a key injected after the flush in interpreted and generated execution. - Regenerate affected goldens; most generated-source changes only update the callback comment.
Readability tradeoff: The redirected-input fixture raises RegisterReads from 12 to 16 for the generated callback-target guard, while tightening Statements from 151 to 149. No new hand-written types or tables are added; most added lines are fixture and golden data.
Validation used source inspection and a bounded EOF-loop check. Project builds and tests were not run in this environment.
| File | Description |
|---|---|
| tests/Spice86.Tests/Resources/GeneratedCodeReadability/speculative_transfer_into_data.spec.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/GeneratedCodeReadability/partition_multi_entry_disconnected_shared.spec.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/GeneratedCodeReadability/flush_input_then_wait_key_ah01.a20.ivt.spec.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/GeneratedCodeReadability/flush_input_then_read_ah01.a20.ivt.spec.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/GeneratedCodeReadability/flush_input_al00_returns.a20.ivt.spec.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/DosInt21Tests/flush_input_then_wait_key_ah01.asm | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/DosInt21Tests/flush_input_then_read_ah01.asm | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/DosInt21Tests/flush_input_clears_stuffahead.asm | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/DosInt21Tests/flush_input_al00_returns.asm | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/xms_request_release_umb.pit.ivt.xms.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/write_read_only_handle.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/umb_ems_size.a20.ivt.xms.ems.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/umb_disabled.a20.ivt.xms.noumb.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/umb_chain_link.a20.ivt.xms.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/umb_alloc_strategy.a20.ivt.xms.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr22h.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_zero_paragraphs.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_valid_paragraphs.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_return_code.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_parent_psp_size.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_large_paragraphs.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_interrupt_vector.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_batch_continues.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/tsr_basic.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/terminate_after_create_child_psp_restores_parent_stack.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/stdin_read_ah08.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/stdin_read_ah07.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/stdin_read_ah01.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/stdin_buffered_read_ah0a.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/standard_file_handles_inherited.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/set_handle_count_updates_psp.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/set_handle_count_relocates_jft.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/set_file_attributes_roundtrip.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/select_default_drive.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/seek_device_per_open.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/seek_console_device.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/scroll_up_clears_full_row.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/realloc_test_pad16.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/realloc_test_pad15.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/realloc_test_pad13.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/realloc_test_pad12.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/realloc_test_pad1.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/realloc_test_pad0.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/read_floppy_image_file.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/read_cd_image_file.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/psp_parent_command_com.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/program_arguments_print_argv0.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/program_arguments_access_argv.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/move_file_pointer_signed_offset.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/keyboard_reassignment_reset.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/int16_wait_key_through_chained_int9.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/int16_second_wait_gets_next_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/int16_ah11_extended_key_scan_code.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/int16_ah10_extended_key_scan_code.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/int_service_calls.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/graphics_scroll_moves_rows.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/flush_input_clears_stuffahead.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/find_first_wildcard.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/find_first_short_filename.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/file_handles_are_lowest_free_jft_slot.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/file_attributes_readonly.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/environment_block_not_corrupted.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/environment_block_contains_program_path.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/ems_detection_device_name.pit.ivt.ems.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/dos_int21h.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/dos_fcb_child.pit.ivt.xms.ems.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/dos_exec_modes_and_overlays.pit.ivt.xms.ems.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/device_status_report.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/dbcs_table_private_area.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/dbcs_lead_byte_table_invalid_al.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/dbcs_lead_byte_table_al0.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/data_strings.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/create_new_psp_valid_copy.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/create_directory_empty_path.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/create_child_psp_valid.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/crack_close_handle8_hook.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/control_break_roundtrip.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl0e_z_drive.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl0e_floppy_drive.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl09_z_drive.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl09_fixed_drive.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl07_stdout_ready.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl06_redirect_file_eof_after_read.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl06_redirect_file_empty.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl06_redirect_file_data.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl06_poll_and_read.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl06_keyboard_empty.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl06_keyboard_available.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl00_stdin_character_device.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl_unsupported_11.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl_unsupported_10.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl_unsupported_0f.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ioctl_unsupported_0a.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah0c_flushes_keyboard.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah0b_input_available.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah09_print_string.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah09_ctrl_c_break.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah08_read_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah07_read_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah06_output_redirect.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah06_input_no_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah06_input_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah05_ctrl_c_break.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah04_ctrl_c_break.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah03_ctrl_c_break.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah02_ctrl_c_break.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/console_ah01_read_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/commit_file_buffers.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/child_return_code_subsequent_zero.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/child_return_code_initial.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/child_psp_inherits_jft_slots.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/child_exec_terminate_releases_handles.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/check_stdin_status_ctrl_c.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/check_stdin_status_ctrl_break.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/cds_initialized_known_location.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bootstrap_host_requested_path_with_spaces.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bootstrap_host_requested_exe.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bootstrap_host_requested_exe_subdirectory.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bootstrap_host_requested_batch.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bootstrap_errorlevel_propagates.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bootstrap_arguments_from_host.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bios_disk_parameters_hdd.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bios_disk_parameters_floppy.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/bios_disk_parameters_absent.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_shift_updates_arguments.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_set_env_expansion.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_set_empty_clears_env.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_reading_stops_at_ctrl_z.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_pipe_tight_bar.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_pipe_spaces_around_bar.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_pipe_space_after_bar.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_pipe_input_first_segment.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_pause_redirected_stdin.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_pause_preloaded_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_path_command_expansion.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_output_redirection.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_nested_batch_call.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_multi_input_tight.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_multi_input_spaced.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_maupiti_tatou_nested_directory.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_jill_menu_errorlevel_goto.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_jill_choice_dispatches_exe.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_input_redirection.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_unquoted_comparison.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_string_preserves_quotes.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_string_case_sensitive.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_not_string_comparison.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_not_errorlevel_skips.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_exist_and_not_exist.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_errorlevel_equals_dispatches.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_if_errorlevel_dispatches.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_host_requested_com.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_goto_skips_commands.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_for_wildcard_expands.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_for_mixed_literals_wildcards.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_for_iterates.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_for_equals_delimiter.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_for_comma_semicolon_delimiters.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_exit_stops_execution.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_exit_inside_call_stops_all.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_errorlevel_propagates.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_double_input_operator.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_cls_clears_screen.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_without_colon.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_timeout_keypress.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_timeout_default.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_skips_invalid_keys.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_prompt_text.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_preloaded_key.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_n_flag_prompt.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_n_after_text.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_default_yn_selects_y.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_default_yn_selects_n.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_default_choices_yn.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_custom_keys_third.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_case_sensitive_flag.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_choice_case_insensitive.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_noext_prefers_com_over_bat.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_noext_falls_back_to_exe.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_noext_falls_back_to_com.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_nested_batch_context.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_launches_com.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_label_with_batch.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_label_unknown.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_label_subroutine.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_call_label_nested.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_bare_missing_bat_keeps_context.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_bare_bat_replaces_context.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_append_redirection.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_alpha_waves_f3.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_alpha_waves_f2.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_alpha_waves_f10_bypasses_branches.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_alpha_waves_f1.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/batch_aitd_tatou_noext_prefers_com.pit.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/GeneratedCode/allocation_info_default_drive.a20.ivt.spec.cs.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedListing/speculative_transfer_into_data.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedListing/partition_multi_entry_disconnected_shared.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedListing/flush_input_then_wait_key_ah01.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedListing/flush_input_then_read_ah01.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedListing/flush_input_clears_stuffahead.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedListing/flush_input_al00_returns.txt | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedCfgPartitions/speculative_transfer_into_data.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/res/DumpedCfgBlocks/flush_input_clears_stuffahead.json | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/asmsrc/speculative_transfer_into_data.asm | Updated as part of this pull request. |
| tests/Spice86.Tests/Resources/cpuTests/asmsrc/partition_multi_entry_disconnected_shared.asm | Updated as part of this pull request. |
| tests/Spice86.Tests/GeneratedCodeMachineTest.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/Dos/DosProgramLoaderTests.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/AsmFixtures/Int21ScenarioCatalog.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/AsmFixtures/AsmScenarioCatalog.cs | Updated as part of this pull request. |
| tests/Spice86.Tests/AsmFixtures/AsmFixtureCatalog.cs | Updated as part of this pull request. |
| src/Spice86.Core/Emulator/ReverseEngineer/CfgCodeGeneration/UntestedMessages.cs | Updated as part of this pull request. |
| src/Spice86.Core/Emulator/ReverseEngineer/CfgCodeGeneration/InstructionLowerer.cs | Updated as part of this pull request. |
| src/Spice86.Core/Emulator/ReverseEngineer/CfgCodeGeneration/CfgGeneratorContext.cs | Updated as part of this pull request. |
| src/Spice86.Core/Emulator/OperatingSystem/DosProgramLoader.cs | Updated as part of this pull request. |
| src/Spice86.Core/Emulator/InterruptHandlers/Input/Mouse/MouseDriver.cs | Updated as part of this pull request. |
| src/Spice86.Core/Emulator/InterruptHandlers/Common/Callback/CallbackNumbers.cs | Updated as part of this pull request. |
Review effort: Balanced
a631d03 to
2d76537
Compare
|
@Cyronius thanks ! merged. |

Description of Changes
One commit. It answers the second Copilot review comment on #2482 (now merged): with the console as STDIN and no key pending, INT 21h AX=0C01h returned NUL at once instead of waiting for a key.
INT 21h AH=0Ch flushed the input, then called the C# handler of the function in AL directly. That skipped the stub's STDIN wait loop (STI, readiness callback, INT 28h idle), which AH=07h, 08h and 0Ah go through. So AL=01h, 07h, 08h and 0Ah all returned NUL without waiting.
The change:
ClearKeyboardBufferAndInvokeKeyboardFunctionflushes, then moves CS:IP to the stub's existing STDIN wait loop instead of running the function. Callbacks that move CS:IP are already supported by the CPU and the code generator (ExecuteCallback,CallbackMovedCsIp).DispatchStdinInputinstead ofRun. It runs the function in AH, or for AH=0Ch the function in AL, without flushing again.An earlier version of this fix added an AH=0Ch branch to the stub itself. That moved every BIOS stub address after it and would have raised the readability bounds of the 188 generated fixtures that contain the stub, so I dropped it for this one.
Plain AH=01h (without 0Ch) still goes through the default dispatch, so with the console as STDIN and no key pending it still returns NUL without waiting. That was already the case before, and this PR leaves it alone.
Tests
DosInt21Tests/flush_input_then_wait_key_ah01(new):AX=0C01hwith the console as STDIN and no key pending. The run presses A after the flush (KeyboardSetup, cycle 50), and the call must return'a'.Failure before the fix:
flush_input_then_read_ah01(from #2482, redirected STDIN) still passes. It now goes through the wait loop, which finds STDIN ready at once.Goldens and readability baselines
Regenerated the way
AGENTS.mddescribes: writers enabled, catalogue command run serially twice, writers disabled again. The second pass changed nothing (checked by SHA-256).187 generated programs: one comment line each. The dispatch callback's comment changes from
// INT 21h: Dos services selected by AHto// Spice86 callback: DosInt21Handler.DispatchStdinInput, because the callback now calls a different method. No code line changes, and no readability metric changes.flush_input_then_wait_key_ah01(new): listing, CFG, partitions, generated source, and a readability baseline at the exact measured counts.flush_input_then_read_ah01: the CFG gains the edge from the AH=0Ch callback to the wait loop. In the generated C#, the callback becomes aCallbackMovedCsIpcheck, and the wait loop is no longer speculative, so itsVerifySpeculative...guards go away:Readability bound raised:
flush_input_then_read_ah01.a20.ivt.specRegisterReadsgoes from 12 to 16 (measured 16). The 4 extra reads are CS and IP in the moved-target check, in its condition and in its failure message. That check is the generator's standard form for a callback that moves CS:IP. It is needed for correctness: generated code must fail loudly if the callback lands anywhere other than the observed target.Statementsgoes from 151 to 149 (tighter). No other bound of any fixture changes. This fixture is new in fix: INT 21h AH=0Ch dispatch, nested mouse driver passes, relative -c, and two C# generation aborts #2482, so its baseline has no history before this.Full suite, excluding
SingleStepTest(Fedora 44, .NET 10):Total: 7957, Errors: 0, Failed: 0, Skipped: 0(on current master, 72da247). That run used the xUnit runner directly (Spice86.Tests -class- "*SingleStepTest*"), becausedotnet testwas being killed on this machine under memory pressure from another job. The solution builds with 0 warnings.Suggested Testing Steps
🤖 Generated with Claude Code
https://claude.ai/code/session_01Rh22PkoQR3deb3SC5uZvxL