# CPU模拟器JAVA **Repository Path**: orange_cat_studio/cpu-emulator-java ## Basic Information - **Project Name**: CPU模拟器JAVA - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-03 - **Last Updated**: 2026-06-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CPU Emulator IDE (Java Frontend) A Java Swing-based graphical IDE for the OC CPU Emulator. Communicates with the C emulator backend via TCP socket using a custom binary protocol. ## Features - **Real-time register view** with hex/decimal/binary display - **Memory browser** with hex/ASCII view and inline editing - **Device panel** for listing and interacting with hardware devices - **Breakpoint manager** with add/delete/refresh - **Code editor** for assembly code - **Communication log** for debugging protocol messages - **Keyboard shortcuts**: F5=Step, F6=Go, F7=Stop ## Project Structure ``` cpu-emulator-ide/ ├── src/ │ └── com/cpuemulator/ide/ │ ├── MainFrame.java (entry point) │ ├── net/ │ │ └── ProtocolClient.java (TCP client) │ ├── ui/ │ │ ├── RegisterPanel.java │ │ ├── MemoryPanel.java │ │ ├── DevicePanel.java │ │ ├── BreakpointPanel.java │ │ └── CodeEditor.java │ └── vm/ │ └── EmulatorState.java └── build/ (output) ``` ## Build ### Using javac directly ```bash mkdir -p build javac -d build -sourcepath src src/com/cpuemulator/ide/ui/MainFrame.java ``` ### Run ```bash java -cp build com.cpuemulator.ide.ui.MainFrame ``` ## Protocol The IDE communicates with the C emulator on a TCP port (default 8888). **Packet format:** ``` [2 bytes: magic 0x4350 ("CP")] [1 byte: command] [1 byte: flags] [2 bytes: payload length (little-endian)] [N bytes: payload] [4 bytes: footer "\r\n\r\n"] ``` See `include/vm/protocol.h` in the C emulator for the full command set. ## Starting the C Backend The C emulator must be started with the protocol option: ```bash OC_VM.exe --proto 8888 ``` Then in the IDE, click "Connect" with `127.0.0.1:8888`. ## Quick Start 1. Start the C emulator with protocol support: ``` ./OC_VM.exe --proto 8888 ``` 2. Start the Java IDE: ``` java -cp build com.cpuemulator.ide.ui.MainFrame ``` 3. In the IDE: - Set host/port and click "Connect" - Use Step (F5) to execute one instruction - Use Go (F6) to run continuously - Use Stop (F7) to halt execution - Edit memory by double-clicking cells - Set breakpoints by address ## License Same as the C emulator project.