Per Mårtensson 1 mēnesi atpakaļ
vecāks
revīzija
462e2d09ab
1 mainītis faili ar 422 papildinājumiem un 151 dzēšanām
  1. 422 151
      roms/disasm_with_labels.asm

+ 422 - 151
roms/disasm_with_labels.asm

@@ -22,57 +22,130 @@
 ; followed by hexadecimal parameters. All addresses are 4-digit hex.
 ;
 ; MEMORY EXAMINATION COMMANDS:
-; • M XXXX        - Memory examine/modify starting at address XXXX
+; • M XXXX        - Memory examine/modify starting at address XXXX (Entry: 0x04FCh)
 ;                   Shows: ADDR: YY (where YY is current byte value)
 ;                   Enter new hex value or press Enter to skip
 ;                   Press 'Q' to quit back to monitor
 ;
-; • D XXXX        - Memory dump (hex display) starting at address XXXX
+; • D XXXX        - Memory dump (hex display) starting at address XXXX (Entry: 0x0358h)
 ;                   Format: XXXX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX *................*
 ;                   Shows 32 bytes total (2 lines of 16 bytes each)
 ;                   Non-printable characters shown as '.' in ASCII area
 ;
-; • C XXXX YYYY ZZZZ - Memory compare command
+; • E XXXX YYYY   - Enter/Edit memory data command (Entry: 0x0515h)
+;                   Direct memory data entry starting at address XXXX
+;                   Allows rapid entry of hex byte sequences
+;                   YYYY parameter may specify data length or end address
+;                   More efficient than M command for bulk data entry
+;
+; • C XXXX YYYY ZZZZ - Memory compare command (Entry: l0323h)
 ;                   Compares memory block [XXXX..YYYY] with block starting at ZZZZ
 ;                   Displays differences in format showing both addresses and values
 ;                   Only shows mismatched bytes, silent if blocks are identical
 ;
 ; MEMORY MODIFICATION COMMANDS:
-; • F XXXX YYYY ZZ - Memory fill command
+; • F XXXX YYYY ZZ - Memory fill command (Entry: 0x03B7h)
 ;                   Fills memory from XXXX to YYYY with byte value ZZ
 ;                   Uses efficient Z80 LDIR instruction for fast block operations
 ;
 ; DEBUGGING/BREAKPOINT COMMANDS:
-; • B XXXX        - Set breakpoint or execution counter
+; • B XXXX        - Set breakpoint or execution counter (Entry: 0x0313h)
 ;                   Sets debugging parameters for program execution control
 ;                   Counter stored at memory location 0x011D0
 ;
-; • G XXXX        - Go/Execute program starting from address XXXX
+; • G XXXX        - Go/Execute program starting from address XXXX (Entry: 0x044Ah)
 ;                   Transfers control to user program at specified address
 ;                   Restores all CPU registers and begins execution
 ;                   Supports breakpoint detection and interrupt handling
 ;                   Returns to monitor if breakpoint hit or program exits 
 ;
-; • I XXXX        - Configure debug display parameters and modes
+; • I XXXX        - Configure debug display parameters and modes (Entry: 0x03CFh)
 ;                   Sets debugging display parameters stored at 0x11D6
 ;                   Used for display width, format, or visualization options
 ;                   Special case: "II" jumps to specialized display handler
 ;
-; • J XXXX        - Jump/Execute program (alternate Go command)
+; • J XXXX        - Jump/Execute program (alternate Go command) (Entry: 0x0441h)
 ;                   Similar functionality to G command - executes program
 ;                   Parses hex address and transfers control to user program
 ;                   Supports same breakpoint and register restoration features
 ;
-; • L             - Load/Transfer data operations
-;                   Data loading and transfer command for memory operations
-;                   Supports loading data between memory locations
-;                   May include external storage access capabilities
+; • L XXXX        - Load Intel HEX records into memory (Entry: 0x089Fh)
+;                   Advanced Intel HEX format loader for program/data transfer
+;                   XXXX parameter specifies base load address (optional, defaults to 0x0000)
+;                   Parses Intel HEX records: ":LLAAAATTDDDDDDCC" format
+;                   LL=byte count, AAAA=address, TT=record type, DD=data, CC=checksum
+;                   Validates checksums and loads data to calculated addresses
+;                   Essential for loading programs from external sources or storage
+;                   Searches for ':' record start markers and processes complete records
 ;
 ; SYSTEM DISPLAY COMMANDS:
-; • R             - Register display - Show CPU register contents
+; • R             - Register display - Show CPU register contents (Entry: 0x09FFh)
 ;                   Displays all Z80 registers and system status
 ;                   Shows AF, BC, DE, HL, IX, IY, SP, PC values
 ;
+; SEARCH AND CALCULATION COMMANDS:
+; • S XXXX YYYY   - Search for data pattern in memory range (Entry: 0x093Fh)
+;                   Searches memory from XXXX to YYYY for data pattern
+;                   Pattern specified in subsequent parameter input
+;                   Can search for byte values or multi-byte sequences
+;
+; • N XXXX YYYY   - Numeric calculator (arithmetic operations) (Entry: 0x049Fh)
+;                   Performs calculations on hex values XXXX and YYYY
+;                   Shows results of add, subtract, multiply operations
+;                   Essential for address calculations and data manipulation
+;
+; • H XXXX YYYY   - Hex arithmetic calculator (Entry: 0x0887h)
+;                   Performs hex addition and subtraction on values XXXX and YYYY
+;                   Displays both sum (XXXX + YYYY) and difference (XXXX - YYYY)
+;                   Essential for address calculations and memory arithmetic
+;                   Shows results in 4-digit hexadecimal format
+;
+; • T             - Terminal/System control command (Entry: 0x064Fh)
+;                   Terminal configuration or system test command
+;                   May include hardware timing tests or peripheral checks
+;                   Used for system configuration and validation
+;
+; PORT I/O COMMANDS:
+; • O XXXX YYYY   - Output/Port write operation (Entry: 0x09BCh)
+;                   Writes data YYYY to I/O port XXXX
+;                   Direct hardware control for peripheral programming
+;                   Used for device configuration and control operations
+;                   Essential for configuring SIO, CTC, DMA controllers
+;
+; • P XXXX YYYY   - Patch/Program memory command (Entry: 0x086Fh)
+;                   Advanced memory programming operation from XXXX to YYYY
+;                   May include special programming modes for EPROM/EEPROM
+;                   Could support verification and programming cycles
+;                   Used for in-system programming of memory devices
+;
+; • Q XXXX        - Query/Quick memory display command (Entry: 0x0BCh)
+;                   Quick memory content query and display operation
+;                   Shows memory content at address XXXX with formatted output
+;                   May provide abbreviated display format for rapid inspection
+;                   Alternative to D command for single address queries
+;
+; DATA TRANSFER COMMANDS:
+; • U XXXX YYYY   - Upload/Memory checksum utility (Entry: 0x0924h)
+;                   Computes Intel HEX format checksums for memory range XXXX to YYYY
+;                   Displays memory content in Intel HEX record format with checksums
+;                   Essential for creating ROM images and data verification
+;                   Output format: ":LLAAAATT[DD...]CC" where LL=length, AAAA=address,
+;                   TT=type, DD=data bytes, CC=checksum. Handled by l0924h routine.
+;
+; • W XXXX YYYY   - Write/Memory download command (Entry: 0x09FAh)
+;                   Downloads memory contents from XXXX to YYYY in formatted output
+;                   Creates output suitable for transfer to external systems
+;                   May support various output formats for data export/backup
+;                   Complementary command to U (upload) for memory management
+;
+; EXTENDED SYSTEM COMMANDS:
+; • X             - eXamine/Display all CPU registers (Entry: l040fh)
+;                   Displays complete Z80 register set in formatted output
+;                   Shows AF, BC, DE, HL, AF', BC', DE', HL', IX, IY, I, PC, SP
+;                   Essential for debugging - shows complete CPU state
+;                   Uses register name table at 0x05EB and console buffer setup
+;                   Provides comprehensive register dump for program analysis
+;
 ; ADDITIONAL COMMANDS:
 ; • Debug parameters can be configured via additional commands
 ; • Monitor supports commands: B,C,D,E,F,G,H,I,J,L,M,N,O,P,R,S,T,W,X
@@ -1930,126 +2003,246 @@ l06aah:
 	cp 030h		;06b2 ; Check if >= '0'
 	jr nc,l0694h		;06b4 ; If valid hex character, continue parsing
 	jr l068ch		;06b6 ; Otherwise, end parsing and return result
+
+;==============================================================================
+; 16-BIT HEX ADDRESS FORMATTER (0x06B8)
+;==============================================================================
+; Purpose: Convert 16-bit value in HL to 4-digit hex string and store in output buffer
+; Used extensively throughout the monitor for displaying memory addresses,
+; breakpoint locations, and register values in XXXX format.
+;
+; Input: HL = 16-bit value to format (e.g., memory address)
+; Output: 4-character hex string written to console buffer at (0x011F2)
+;         Followed by a space character for proper formatting
+; Buffer: Updates 0x011F2 pointer to reflect new buffer position
+;
+; Format: Converts 0x1234 → "1234 " (4 hex digits + space)
+; Usage: Called by memory display, breakpoint display, register dump routines
+;
+; Technical Details:
+; • Processes high byte (H) first, then low byte (L)  
+; • Each byte converted to 2 hex characters using sub_06c6h
+; • Automatically adds space separator after hex digits
+; • Updates buffer pointer for subsequent output operations
+;==============================================================================
 sub_06b8h:
-	ld a,h			;06b8
-	call sub_06c6h		;06b9
-	push hl			;06bc
-	ld hl,(011f2h)		;06bd
-	dec hl			;06c0
-	ld (011f2h),hl		;06c1
-	pop hl			;06c4
-	ld a,l			;06c5
+	ld a,h			;06b8 ; Load high byte of 16-bit value
+	call sub_06c6h		;06b9 ; Convert high byte to 2 hex characters
+	push hl			;06bc ; Save original 16-bit value
+	ld hl,(011f2h)		;06bd ; Load current console buffer pointer
+	dec hl			;06c0 ; Back up one position (preparation for space)
+	ld (011f2h),hl		;06c1 ; Update buffer pointer
+	pop hl			;06c4 ; Restore original 16-bit value
+	ld a,l			;06c5 ; Load low byte of 16-bit value
+
+;==============================================================================
+; SINGLE BYTE HEX FORMATTER (0x06C6)
+;==============================================================================
+; Purpose: Convert single byte to 2-digit hex string and store in output buffer
+; Input: A = byte value to convert (0x00-0xFF)
+; Output: 2-character hex string written to buffer, followed by space
+; Used by: 16-bit formatter above, and other hex display routines
+;==============================================================================
 sub_06c6h:
-	push hl			;06c6
-	ld hl,(011f2h)		;06c7
-	call sub_06d6h		;06ca
-	inc hl			;06cd
-	ld (hl),020h		;06ce
-	inc hl			;06d0
-	ld (011f2h),hl		;06d1
-	pop hl			;06d4
+	push hl			;06c6 ; Save registers
+	ld hl,(011f2h)		;06c7 ; Load current console buffer pointer
+	call sub_06d6h		;06ca ; Convert byte to 2 hex characters at buffer
+	inc hl			;06cd ; Move past the 2 hex characters
+	ld (hl),020h		;06ce ; Store space character (0x20) for separation
+	inc hl			;06d0 ; Move past space character
+	ld (011f2h),hl		;06d1 ; Update buffer pointer to new position
+	pop hl			;06d4 ; Restore registers
 	ret			;06d5
+
+;==============================================================================
+; BYTE TO HEX DIGIT CONVERTER (0x06D6)
+;==============================================================================
+; Purpose: Convert single byte to 2 ASCII hex characters
+; Input: A = byte value, HL = buffer location
+; Output: 2 hex characters stored at HL and HL+1
+; Method: Splits byte into high/low nibbles, converts each to ASCII hex
+;==============================================================================
 sub_06d6h:
-	push af			;06d6
-	rra			;06d7
-	rra			;06d8
+	push af			;06d6 ; Save original byte value
+	rra			;06d7 ; Rotate right 4 times to get high nibble
+	rra			;06d8 ; in low 4 bits
 	rra			;06d9
 	rra			;06da
-	call sub_06e0h		;06db
-	inc hl			;06de
-	pop af			;06df
+	call sub_06e0h		;06db ; Convert high nibble to hex character
+	inc hl			;06de ; Move to next buffer position
+	pop af			;06df ; Restore original byte value
+
+;==============================================================================
+; NIBBLE TO HEX CHARACTER CONVERTER (0x06E0)
+;==============================================================================
+; Purpose: Convert single nibble (0-15) to ASCII hex character
+; Input: A = nibble value (0-15), HL = buffer location
+; Output: ASCII hex character ('0'-'9', 'A'-'F') stored at (HL)
+;==============================================================================
 sub_06e0h:
-	and 00fh		;06e0
-	cp 00ah		;06e2
-	jr c,l06e8h		;06e4
-	add a,007h		;06e6
+	and 00fh		;06e0 ; Mask to get only low 4 bits (nibble)
+	cp 00ah		;06e2 ; Compare with 10
+	jr c,l06e8h		;06e4 ; If < 10, convert to '0'-'9'
+	add a,007h		;06e6 ; If >= 10, add 7 to convert to 'A'-'F'
 l06e8h:
-	add a,030h		;06e8
-	ld (hl),a			;06ea
-	ret			;06eb
+	add a,030h		;06e8 ; Add ASCII '0' offset to get final character
+	ld (hl),a			;06ea ; Store ASCII hex character in buffer
+	ret			;06eb ; Return
+
+;==============================================================================
+; CONSOLE OUTPUT FORMATTER & UTILITIES (0x06EC-0x076F)
+;==============================================================================
+; Collection of routines for formatting and outputting data to the console
+; with proper control characters and formatting.
+;==============================================================================
+
+;==============================================================================
+; STRING DISPLAY WITH CONTROL FORMATTING (0x06EC)
+;==============================================================================
+; Purpose: Display string from HL with proper control character formatting
+; Adds ETX (0x02) prefix and EOT (0x03) suffix around displayed text
+; Used for formatted console output with control framing
+;==============================================================================
 l06ech:
-	inc hl			;06ec
-	ld c,002h		;06ed
-	call sub_0111h		;06ef
+	inc hl			;06ec ; Move to start of string data
+	ld c,002h		;06ed ; Load ETX control character (Start of Text)
+	call sub_0111h		;06ef ; Send ETX to serial port
 l06f2h:
-	ld a,(hl)			;06f2
-	cp 020h		;06f3
-	jr z,l0702h		;06f5
-	cp 00dh		;06f7
-	jr z,l0702h		;06f9
-	ld c,a			;06fb
-	call sub_0111h		;06fc
-	inc hl			;06ff
-	jr l06f2h		;0700
+	ld a,(hl)			;06f2 ; Load next character from string
+	cp 020h		;06f3 ; Check if space character (end marker)
+	jr z,l0702h		;06f5 ; If space, end string output
+	cp 00dh		;06f7 ; Check if carriage return (end marker)
+	jr z,l0702h		;06f9 ; If CR, end string output
+	ld c,a			;06fb ; Load character into C for output
+	call sub_0111h		;06fc ; Send character to serial port
+	inc hl			;06ff ; Move to next character
+	jr l06f2h		;0700 ; Continue until end marker found
 l0702h:
-	ld c,003h		;0702
-	call sub_0111h		;0704
-	ret			;0707
+	ld c,003h		;0702 ; Load EOT control character (End of Text)
+	call sub_0111h		;0704 ; Send EOT to serial port
+	ret			;0707 ; Return
+
+;==============================================================================
+; HEX BYTE DISPLAY WITH INPUT PROMPT (0x0708)
+;==============================================================================
+; Purpose: Display byte value and prompt for user input
+; Used by memory examination commands for interactive editing
+;==============================================================================
 sub_0708h:
-	call sub_06c6h		;0708
+	call sub_06c6h		;0708 ; Format and display byte as 2-digit hex + space
+
+;==============================================================================
+; CONSOLE OUTPUT FLUSH AND INPUT PROMPT (0x070B)
+;==============================================================================  
+; Purpose: Flush current output buffer and prompt for user input
+; Sets up interactive prompt with space character and waits for input
+;==============================================================================
 sub_070bh:
-	call sub_0745h		;070b
-	ld a,020h		;070e
-	ld (011f6h),a		;0710
-	call sub_080dh		;0713
-	cp 051h		;0716
-	ret z			;0718
-	ld hl,01168h		;0719
-	ld (hl),020h		;071c
-	ld (011f4h),hl		;071e
-	push de			;0721
-	call sub_0680h		;0722
-	pop de			;0725
-	ret			;0726
+	call sub_0745h		;070b ; Flush output buffer to console
+	ld a,020h		;070e ; Load space character
+	ld (011f6h),a		;0710 ; Set prompt character to space
+	call sub_080dh		;0713 ; Get character from user input
+	cp 051h		;0716 ; Check if 'Q' (quit command)
+	ret z			;0718 ; Return if user wants to quit
+	ld hl,01168h		;0719 ; Load input buffer address
+	ld (hl),020h		;071c ; Initialize buffer with space
+	ld (011f4h),hl		;071e ; Set input buffer pointer
+	push de			;0721 ; Save DE register
+	call sub_0680h		;0722 ; Parse hex input from user
+	pop de			;0725 ; Restore DE register
+	ret			;0726 ; Return
+
+;==============================================================================
+; OUTPUT BUFFER MANAGEMENT ROUTINES (0x0727-0x076F)
+;==============================================================================
+; Purpose: Handle console output buffer operations including line formatting,
+; buffer flushing, and register preservation during I/O operations
+;==============================================================================
+
+;==============================================================================
+; SET OUTPUT BUFFER POINTER (0x0727)
+;==============================================================================
 l0727h:
-	ld (011f2h),hl		;0727
+	ld (011f2h),hl		;0727 ; Store HL as new output buffer pointer
+
+;==============================================================================
+; FLUSH OUTPUT WITH NEWLINE (0x072A)
+;==============================================================================
+; Purpose: Add CR/LF to output buffer and flush to console
+; Preserves all registers during output operation
+;==============================================================================
 sub_072ah:
-	push hl			;072a
+	push hl			;072a ; Save all registers
 	push de			;072b
 	push bc			;072c
-	ld hl,(011f2h)		;072d
-	ld (hl),00dh		;0730
-	inc hl			;0732
-	ld (hl),00ah		;0733
-	inc hl			;0735
+	ld hl,(011f2h)		;072d ; Load current buffer pointer
+	ld (hl),00dh		;0730 ; Add carriage return
+	inc hl			;0732 ; Move to next position
+	ld (hl),00ah		;0733 ; Add line feed
+	inc hl			;0735 ; Move to next position
 l0736h:
-	ld (hl),000h		;0736
-	ld hl,01104h		;0738
-	ld (011f2h),hl		;073b
-	call l00fdh		;073e
-	pop bc			;0741
+	ld (hl),000h		;0736 ; Add null terminator
+	ld hl,01104h		;0738 ; Reset buffer pointer to start
+	ld (011f2h),hl		;073b ; Update buffer pointer
+	call l00fdh		;073e ; Send buffer contents to console
+	pop bc			;0741 ; Restore all registers
 	pop de			;0742
 	pop hl			;0743
-	ret			;0744
+	ret			;0744 ; Return
+
+;==============================================================================
+; FLUSH OUTPUT WITHOUT NEWLINE (0x0745)
+;==============================================================================
+; Purpose: Flush current output buffer to console without adding newline
+; Used for partial line output and formatting
+;==============================================================================
 sub_0745h:
-	push hl			;0745
+	push hl			;0745 ; Save all registers
 	push de			;0746
 	push bc			;0747
-	ld hl,(011f2h)		;0748
-	jr l0736h		;074b
+	ld hl,(011f2h)		;0748 ; Load current buffer pointer
+	jr l0736h		;074b ; Jump to common flush routine
+
+;==============================================================================
+; OUTPUT BUFFER WITH CHARACTER INPUT (0x074D)
+;==============================================================================
+; Purpose: Flush output buffer and get character input from console
+; Returns input character while preserving registers
+;==============================================================================
 sub_074dh:
-	push hl			;074d
+	push hl			;074d ; Save registers
 	push de			;074e
-	ld hl,(011f2h)		;074f
-	ld (hl),000h		;0752
-	ld hl,01104h		;0754
-	ld (011f2h),hl		;0757
-	call l0107h		;075a
-	pop de			;075d
+	ld hl,(011f2h)		;074f ; Load current buffer pointer
+	ld (hl),000h		;0752 ; Add null terminator
+	ld hl,01104h		;0754 ; Reset buffer pointer to start
+	ld (011f2h),hl		;0757 ; Update buffer pointer
+	call l0107h		;075a ; Output buffer and get input character
+	pop de			;075d ; Restore registers
 	pop hl			;075e
-	ret			;075f
+	ret			;075f ; Return with input character in A
+
+;==============================================================================
+; MULTI-PARAMETER HEX INPUT PARSER (0x0760-0x076F)
+;==============================================================================
+; Purpose: Parse multiple hexadecimal parameters from user input
+; Returns parsed values in HL, DE, and BC registers
+;==============================================================================
 sub_0760h:
-	call sub_0680h		;0760
+	call sub_0680h		;0760 ; Parse first hex parameter → HL
+
+;==============================================================================
+; TWO-PARAMETER HEX INPUT PARSER (0x0763)
+;==============================================================================
 sub_0763h:
-	push hl			;0763
-	call sub_0680h		;0764
-	push hl			;0767
-	call sub_0680h		;0768
-	ld b,h			;076b
-	ld c,l			;076c
-	pop hl			;076d
-	pop de			;076e Restore DE register
-	ret			;076f Return to caller
+	push hl			;0763 ; Save first parameter
+	call sub_0680h		;0764 ; Parse second hex parameter → HL
+	push hl			;0767 ; Save second parameter  
+	call sub_0680h		;0768 ; Parse third hex parameter → HL
+	ld b,h			;076b ; Store third parameter high byte in B
+	ld c,l			;076c ; Store third parameter low byte in C
+	pop hl			;076d ; Restore second parameter to HL
+	pop de			;076e ; Restore first parameter to DE
+	ret			;076f ; Return: DE=1st param, HL=2nd param, BC=3rd param
 
 ;==============================================================================
 ; COMPLETE CPU STATE SAVE ROUTINE (sub_0770h) - CRITICAL SYSTEM COMPONENT
@@ -2292,40 +2485,95 @@ l084bh:
 	inc b			;085e ; Increment remaining character count (one less char used)
 	dec hl			;085f ; Move buffer pointer back one position
 	jr l081ch		;0860 ; Return to main input loop
+
+;==============================================================================
+; NEWLINE OUTPUT ROUTINE (0x0862)
+;==============================================================================
+; Purpose: Send carriage return and line feed to console
+; This routine outputs a proper newline sequence (CR+LF) to move the cursor
+; to the beginning of the next line on the terminal.
+;
+; Input: None
+; Output: CR (0x0D) followed by LF (0x0A) sent to console
+; Used by: Console formatting, command completion, line breaks in output
+;
+; Technical Details:
+; • Preserves BC register during operation
+; • Uses sub_0127h (console output with transmitter ready check)
+; • Implements standard DOS/Windows-style line ending (CR+LF)
+; • Essential for proper terminal cursor positioning
+;==============================================================================
 sub_0862h:
-	push bc			;0862
-	ld c,00dh		;0863
-	call sub_0127h		;0865
-	ld c,00ah		;0868
-	call sub_0127h		;086a
-	pop bc			;086d
-	ret			;086e
-	call sub_065eh		;086f
-	cp 055h		;0872
-	jp z,l0924h		;0874
-	call sub_0680h		;0877
-	ld c,l			;087a
-	ld b,h			;087b
-	in a,(c)		;087c
-	push bc			;087e
-	call sub_0708h		;087f
-	pop bc			;0882
-	ret z			;0883
-	out (c),a		;0884
-	ret			;0886
-	call sub_0680h		;0887
-	push hl			;088a
-	call sub_0680h		;088b
-	ex de,hl			;088e
-	pop hl			;088f
-	push hl			;0890
-	add hl,de			;0891
-	call sub_06b8h		;0892
-	pop hl			;0895
-	or a			;0896
-	sbc hl,de		;0897
-	call sub_06b8h		;0899
-	jp sub_072ah		;089c
+	push bc			;0862 ; Save BC register
+	ld c,00dh		;0863 ; Load Carriage Return character (CR, 0x0D)
+	call sub_0127h		;0865 ; Send CR to console (move cursor to line start)
+	ld c,00ah		;0868 ; Load Line Feed character (LF, 0x0A)  
+	call sub_0127h		;086a ; Send LF to console (move cursor to next line)
+	pop bc			;086d ; Restore BC register
+	ret			;086e ; Return
+
+;==============================================================================
+; PORT INPUT/OUTPUT COMMAND (I/O Operations) - (0x086F-0x0886)
+;==============================================================================
+; Purpose: Interactive port I/O operations for hardware testing and control
+; Allows user to read from and write to I/O ports with hex parameters
+;
+; Operation:
+; 1. Check for 'U' modifier (possibly "UP" or "UPDATE" command)
+; 2. Parse port address from user input
+; 3. Read current value from port and display it
+; 4. Prompt user for new value (or 'Q' to quit without change)
+; 5. If new value provided, write it to the port
+;
+; Usage: I PPPP [VV] where PPPP=port address, VV=optional value to write
+; Interactive: Shows current port value, prompts for new value
+;==============================================================================
+l086fh:					; Port I/O command entry point
+	call sub_065eh		;086f ; Get next character from input buffer
+	cp 055h		;0872 ; Check if character is 'U' (0x55)
+	jp z,l0924h		;0874 ; If 'U', jump to special U command handler
+	call sub_0680h		;0877 ; Parse port address from user input → HL
+	ld c,l			;087a ; Load port address low byte into C
+	ld b,h			;087b ; Load port address high byte into B
+	in a,(c)		;087c ; Read current value from I/O port
+	push bc			;087e ; Save port address
+	call sub_0708h		;087f ; Display current port value in hex + prompt for input
+	pop bc			;0882 ; Restore port address
+	ret z			;0883 ; Return if user pressed 'Q' (quit without changes)
+	out (c),a		;0884 ; Write new value (from user input) to I/O port
+	ret			;0886 ; Return
+
+;==============================================================================
+; ARITHMETIC CALCULATOR COMMAND (+ Addition/Subtraction) - (0x0887-0x089C)
+;==============================================================================
+; Purpose: Perform arithmetic operations on two hex values
+; Calculates both addition (A+B) and subtraction (A-B) results
+; Displays both results in hex format for comparison
+;
+; Operation:
+; 1. Parse first hex parameter (A)
+; 2. Parse second hex parameter (B)  
+; 3. Calculate A+B (addition result)
+; 4. Calculate A-B (subtraction result)
+; 5. Display both results in hex format
+;
+; Usage: + AAAA BBBB (where AAAA and BBBB are hex values)
+; Output: Shows both sum and difference in hex format
+;==============================================================================
+l0887h:					; Arithmetic calculator entry point
+	call sub_0680h		;0887 ; Parse first hex parameter → HL (value A)
+	push hl			;088a ; Save first parameter (A)
+	call sub_0680h		;088b ; Parse second hex parameter → HL (value B)
+	ex de,hl			;088e ; Move second parameter (B) to DE
+	pop hl			;088f ; Restore first parameter (A) to HL
+	push hl			;0890 ; Save first parameter again for subtraction
+	add hl,de			;0891 ; Calculate A + B (addition)
+	call sub_06b8h		;0892 ; Display addition result in hex format
+	pop hl			;0895 ; Restore first parameter (A)
+	or a			;0896 ; Clear carry flag for subtraction
+	sbc hl,de			;0897 ; Calculate A - B (subtraction)
+	call sub_06b8h		;0899 ; Display subtraction result in hex format
+	jp sub_072ah		;089c ; Add newline and flush output buffer
 
 ; =============================================================================
 ; LOAD/TRANSFER DATA COMMAND (L command) - Memory/Storage Operations
@@ -2563,10 +2811,33 @@ sub_09a3h:
 l09b6h:
 	ld sp,01400h		;09b6 ; Reset stack pointer to system default
 	jp l02cch		;09b9 ; Jump to main monitor command loop (clean restart)
-	call sub_065eh		;09bc
-	cp 053h		;09bf
-	jp z,l0fbbh		;09c1
-	call sub_0680h		;09c4
+
+;==============================================================================
+; FLOPPY DISK CONTROLLER COMMAND HANDLER (0x09BC-0x09F9)
+;==============================================================================
+; Purpose: Parse and validate floppy disk control parameters
+; Input Format: Multiple hex parameters specifying drive, track, sector settings
+; Parameters:
+;   • Drive Number (0-3): Selects physical floppy drive unit
+;   • Control Flags (0-1): Drive control options and formatting modes
+;   • Track/Cylinder (0-76): Physical track number on disk (max 77 tracks)
+;   • Sector Count (1-26): Number of sectors to process (max 27 sectors)
+;
+; Memory Storage Locations:
+;   • 0x1202: Drive number (0-3)
+;   • 0x1226: Drive control flags (0 or 1) 
+;   • 0x1225: Track/cylinder number (0-76)
+;   • 0x1227: Sector count (1-26)
+;   • 0x11F7: Operation status flag (set to 0xFF when ready)
+;
+; Error Handling: Jumps to l02d9h (error handler) for invalid parameters
+; Used by: Floppy disk read/write/format operations via NEC µPD765A FDC
+;==============================================================================
+l09bch:					; Floppy Disk Parameter Parser Entry Point
+	call sub_065eh		;09bc Get next character from input buffer
+	cp 053h		;09bf Compare with 'S' (0x53 = ASCII 'S' for special command)
+	jp z,l0fbbh		;09c1 If 'S', jump to special disk handler
+	call sub_0680h		;09c4 Parse hex parameter (drive number)
 	cp 004h		;09c7 Check if drive number >= 4 (invalid)
 	jp nc,l02d9h		;09c9 Jump to error if invalid drive number
 	ld (01202h),a		;09cc Store valid drive number (0-3)
@@ -2578,15 +2849,15 @@ l09b6h:
 	cp 04dh		;09dd Check if parameter < 77 (0x4D, max tracks)
 	jp nc,l02d9h		;09df Jump to error if parameter >= 77
 	ld (01225h),a		;09e2 Store drive parameter/selector (track/cylinder)
-	call sub_0680h		;09e5
-	or a			;09e8
-	jp z,l02d9h		;09e9
-	cp 01bh		;09ec
-	jp nc,l02d9h		;09ee
-	ld (01227h),a		;09f1
-	ld a,0ffh		;09f4
-	ld (011f7h),a		;09f6
-	ret			;09f9
+	call sub_0680h		;09e5 Parse final parameter (sector count)
+	or a			;09e8 Check if sector count is zero (invalid)
+	jp z,l02d9h		;09e9 Jump to error if zero sectors specified
+	cp 01bh		;09ec Check if sector count >= 27 (0x1B, max sectors)
+	jp nc,l02d9h		;09ee Jump to error if too many sectors
+	ld (01227h),a		;09f1 Store valid sector count (1-26)
+	ld a,0ffh		;09f4 Load 0xFF (operation ready flag)
+	ld (011f7h),a		;09f6 Set operation status flag (ready for disk operations)
+	ret			;09f9 Return to caller with parameters validated and stored
 	ld hl,l0db1h		;09fa
 	jr l0a0ah		;09fd
 	call sub_065eh		;09ff