{"_id":"8086emu","_rev":"2-f44e852f721f13b0abd00bec417c8412","name":"8086emu","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"8086emu","version":"0.1.0","license":"MIT","_id":"8086emu@0.1.0","maintainers":[{"name":"danish9661","email":"9661346164h@gmail.com"}],"homepage":"https://github.com/danish9661/8086emu#readme","bugs":{"url":"https://github.com/danish9661/8086emu/issues"},"dist":{"shasum":"0563a53b1616ae98b2c8a897699bb6baeb5d013e","tarball":"https://registry.npmjs.org/8086emu/-/8086emu-0.1.0.tgz","fileCount":6,"integrity":"sha512-/dqZN99mwcjAUItl/2DNEzOyUdjAkc0lpYwBOyhcHdSolzzm34gppBBcjt+8QqgWgXBmSyBUdpeyHCnAhnR5PQ==","signatures":[{"sig":"MEYCIQC9vBS/9wAjyyLExkJwPq+NqL3sz6tehIJA0ihNjnwLFwIhAMEMMpcwB6lAXzr5/r0ArPs5+RrBRZY8TimCRHShE1TK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":600543},"main":"multi_cpu_emu.js","type":"module","types":"multi_cpu_emu.d.ts","gitHead":"c535dc746a3164c16a5310f5c4f82b0eadede1a1","_npmUser":{"name":"danish9661","email":"9661346164h@gmail.com"},"repository":{"url":"git+https://github.com/danish9661/8086emu.git","type":"git"},"_npmVersion":"10.8.2","description":"8086 / 8085 / 8051 / 6502 / Z80 / RISC-V emulator cores in one Rust crate, compiles to WASM","directories":{},"sideEffects":["./snippets/*"],"_nodeVersion":"20.20.2","collaborators":["Danish"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/8086emu_0.1.0_1788293959595_0.2262186068609484","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"_id":"8086emu@1.0.0","bugs":{"url":"https://github.com/danish9661/8086emu/issues"},"dist":{"shasum":"b807176903b4ff8f99317347f5cbb34c9339cb81","tarball":"https://registry.npmjs.org/8086emu/-/8086emu-1.0.0.tgz","fileCount":6,"integrity":"sha512-Iv3tzA6G/Wd/jo0bEXEt+qP+6c348Ipn4us5fjGLG4j4pyzof9JtShvRBAcDRu131EumZupuavTxElDqmjPFvQ==","signatures":[{"sig":"MEYCIQDiLUbOQPp9Ca8NAF9cDsJwlsjtBaqx4b0HgBUo8S362QIhAPZDTfnnLLKNxWDS2v3cTds1waPE3Efmuz1KhNZqxkOs","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDLLjtBnnEdgNRoMKgJUDVI93WL1RPUf7JruwcHNu1ACAiEAmOQc1LVnbvGEc79nKF5yGv3ckAV6rK+1uJT842/6Rhg="}],"unpackedSize":600543},"main":"multi_cpu_emu.js","name":"8086emu","type":"module","types":"multi_cpu_emu.d.ts","gitHead":"9e43dc40325b26adaddbc286027a763a58f34abd","license":"MIT","version":"1.0.0","_npmUser":{"name":"danish9661","email":"9661346164h@gmail.com"},"homepage":"https://github.com/danish9661/8086emu#readme","repository":{"url":"git+https://github.com/danish9661/8086emu.git","type":"git"},"_npmVersion":"10.8.2","description":"8086 / 8085 / 8051 / 6502 / Z80 / RISC-V emulator cores in one Rust crate, compiles to WASM","directories":{},"maintainers":[{"name":"danish9661","email":"9661346164h@gmail.com"}],"sideEffects":["./snippets/*"],"_nodeVersion":"20.20.2","collaborators":["Danish"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/8086emu_1.0.0_1788295058704_0.5800235765897483"}}},"time":{"created":"2026-09-01T20:19:19.443Z","modified":"2026-09-01T20:37:39.067Z","0.1.0":"2026-09-01T20:19:19.759Z","1.0.0":"2026-09-01T20:37:38.801Z"},"bugs":{"url":"https://github.com/danish9661/8086emu/issues"},"license":"MIT","homepage":"https://github.com/danish9661/8086emu#readme","repository":{"url":"git+https://github.com/danish9661/8086emu.git","type":"git"},"description":"8086 / 8085 / 8051 / 6502 / Z80 / RISC-V emulator cores in one Rust crate, compiles to WASM","maintainers":[{"name":"danish9661","email":"9661346164h@gmail.com"}],"readme":"# multi-cpu-emu\n\nA single Rust crate that emulates six classic microprocessors:\n\n- **Intel 8086** — 16-bit, segmented, 1 MiB address space; includes an 8259 PIC\n  and 8253 PIT so timer interrupts (IRQ0 → `INT 8`) fire end-to-end\n- **Intel 8085** — 8-bit, 64 KiB, accumulator-centric\n- **Intel 8051 (MCS-51)** — 8-bit, SFRs, bit-addressable RAM, timers\n- **MOS 6502** — 8-bit, decimal mode, NMI/IRQ/BRK vectoring\n- **Zilog Z80** — 8-bit, IM 0/1/2, NMI/INT, full 8080 + Z80 ops\n- **RISC-V rv32i (+M)** — 32-bit, base integer ISA plus the M-extension\n\nEach core has a matching assembler, and the whole crate compiles to **one WASM\nmodule** (via `wasm-bindgen`, feature `wasm`) plus a native `rlib`/`cdylib`.\nA full dependency-free web IDE for students lives in `docs/` and deploys to\nGitHub Pages with zero config.\n\nDesign was inspired by https://github.com/abuXsarkar/modern8086 (MIT) — used\nonly as an architecture/scope reference; all code here is written from scratch.\nSee `AGENTS.md` for the full architecture and per-ISA coverage.\n\n## Build & test\n\n```bash\ncargo test                         # ~86 integration tests across all three ISAs\ncargo clippy --all-targets         # should be warning-free\n\n# wasm build (needs wasm-pack)\nwasm-pack build --target web --out-dir docs/pkg --release --features wasm\n\n# self-contained WASM smoke test (exercises all three ISAs + new features)\nnode tools/wasm-smoke.mjs\n\n# serve the web demo\npython3 -m http.server -d docs 8000   # then open http://localhost:8000\n```\n\n## Web IDE / GitHub Pages\n\nThe demo in `docs/` is a student-oriented IDE: ISA selector (8086/8085/8051),\nsample programs, line-numbered editor with assemble-error highlighting, step /\nstep-over / run / stop / reset, **click-in-gutter breakpoints** with Step-Back\ntime-travel, live register + flag panels, a memory dump with the PC highlighted,\na **live memory-map** (showing loaded ROM / external SRAM / 8051 EA state), an\n**8051 SFR readout** (click a register to edit it live), and a program-output\nconsole.\n\nDeployment is handled by the workflow in `.github/workflows/pages.yml`: on every\npush to `main` it builds the wasm pkg, runs the native tests, and deploys\n`docs/` to GitHub Pages.\n\nOne-time setup in GitHub: **Settings → Pages → Source: \"GitHub Actions\"** (the\nfirst workflow run may enable the site automatically). The site then appears at\n`https://<user>.github.io/8086emu/`.\n\nAlternative (no workflow): **Settings → Pages → Deploy from a branch → `main`,\nfolder `/docs`** — works because all asset paths in `docs/` are relative and the\nprebuilt `docs/pkg/` is committed. After any Rust change, rebuild and commit it:\n`wasm-pack build --target web --out-dir docs/pkg --release --features wasm`.\nRoot `index.html` redirects to `docs/` for local convenience.\n\n## Quick start\n\n### Run headless from a shell (CLI)\n\nThe CLI lives in `examples/run.rs`; it assembles source and runs the program,\nprinting registers, flags, and output.\n\n```bash\n# build once\ncargo build --release --example run\n\n# 8086 hello world\ncargo run --example run -- examples/hello.asm\n\n# other ISAs, with a step cap\ncargo run --example run -- --isa 8051 --max-steps 1000 examples/hello51.asm\n\n# trace every instruction + peripheral (port) write\ncargo run --example run -- --isa 8085 --verbose examples/traffic.asm\n\n# automate checks (exit 0 = pass, 1 = fail, 2 = usage error)\ncargo run --example run -- --grade tests/spec.txt examples/prog.asm\n\n# measure emulation throughput (native numbers)\ncargo run --example run -- --bench            # default 10M steps\ncargo run --example run -- --bench 2000000 --isa rv32\n```\n\n### Use it in the browser (WASM IDE)\n\n```bash\n# serve the demo (from repo root)\npython3 -m http.server -d docs 8000\n# open http://localhost:8000  (root redirects to /docs/)\n```\n\nIn the IDE: pick an ISA → write code → `F7` assemble → `F5` run / `F8` step →\nset breakpoints in the gutter → inspect registers, memory, and device panels.\n\n**Browser throughput check** (open DevTools console on the IDE page; the\nemulator is exposed as `window.emu`):\n\n```js\nlet t = performance.now();\nlet s = emu.run(1_000_000);          // steps executed\nlet ms = performance.now() - t;\nconsole.log(s, 'steps in', ms.toFixed(1), 'ms =>', Math.round(s / (ms/1000)), 'steps/sec');\n```\n\nBoth the CLI and the browser run the **same Rust core** (native vs WASM), so\nbulk `run()` throughput is comparable; only per-instruction single-stepping\nfrom JS is slower because of the JS↔WASM call boundary.\n\n\n## Examples\n\n| File | ISA | Shows |\n|---|---|---|\n| `examples/hello.asm` | 8086 | `INT 21h` string output |\n| `examples/hello85.asm` | 8085 | `OUT 01h` printing |\n| `examples/hello51.asm` | 8051 | `SBUF` serial output |\n| `examples/8155.asm` | 8085 | 8155 external RAM/I/O |\n| `examples/timer51.asm` | 8051 | timer + interrupt |\n| `examples/ser.rs` | 8051 | native serial-RX injection |\n| `examples/bios.asm` | 8086 | BIOS image that boots from the reset vector `FFFF:FFF0` |\n\n## Layout\n\n```\n├── src/\n│   ├── lib.rs          # Emulator facade over the three cores\n│   ├── cpu.rs          # Cpu trait, Mem, Output, FlagSet, Reg, RunResult\n│   ├── i8086.rs        # 8086 CPU core (segmented, INT 21h/10h subset)\n│   ├── i8085.rs        # 8085 CPU core (full 8-bit ISA)\n│   ├── mcs51.rs        # 8051 CPU core (SFRs, bit ops, timers)\n│   ├── asm/            # tokenizer + per-ISA assemblers\n│   └── wasm.rs         # wasm-bindgen surface (feature = \"wasm\")\n├── examples/run.rs     # native CLI runner\n├── tests/emulation.rs  # integration tests\n├── docs/               # GitHub Pages IDE (index.html + app.js + style.css + pkg/)\n└── index.html          # redirects to docs/\n```\n\n## WASM API\n\n```js\nconst emu = new Emulator(\"8086\");            // \"8086\" | \"8085\" | \"8051\"\nconst code = emu.assemble(src);              // throws on error\nemu.load(code, 0x100);                       // write code + set PC\nemu.set_pc(0x100);                           // (re)set the program counter\nemu.run(1_000_000);                          // steps executed\nemu.step();  emu.run_to(targetPc, 1_000_000); // step / run-to-line (Step-Over)\nemu.pc();  emu.regs();  emu.flags();         // \"AX=1234\" / \"ZF\"\nemu.mem(0, 64);                              // raw bytes\nemu.out();                                   // program output (drains)\nemu.halted();  emu.reset();\nemu.snapshot();  emu.restore(bytes);         // deterministic time-travel\n\n// External memory (write-protected ROM / external SRAM / 8051 EA):\nemu.set_rom_region(0xF0000, 0x10000);        // mark ROM range\nemu.load_rom(bytes, 0xF0000);                // place a firmware image\nemu.set_ea(false);                           // 8051: fetch code from XDATA\nemu.set_sram(0x9000, 0x2000);                // 8085: (re)map external SRAM\nemu.rom_region();  emu.sram_region();        // live memory-map info\nemu.ea_active();  emu.ext_code_region();\n\n// 8051 peripheral registers:\nemu.sfr(0xD0);  emu.set_sfr(0xD0, 0x00);     // read/write an SFR\n```\n\n## Program output conventions\n\n- **8086** — `INT 21h` (AH=02, 06, 09, 4Ch) and `INT 10h` (AH=0Eh) write to the\n  output buffer.\n- **8085** — `OUT 01h` prints the char in A.\n- **8051** — writing to `SBUF` prints the char.","readmeFilename":"README.md"}