{"id":16509080,"url":"https://github.com/hemanta212/8085-simulator","last_synced_at":"2026-04-12T03:31:51.744Z","repository":{"id":104360508,"uuid":"453763598","full_name":"hemanta212/8085-simulator","owner":"hemanta212","description":"A simple interpreter for emulating 8085 microprocessor instructions with CLI , REPL and Emacs org-mode interface.","archived":false,"fork":false,"pushed_at":"2022-03-19T18:25:31.000Z","size":151,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T05:42:09.976Z","etag":null,"topics":["8085","8085-interpreter","8085-simulator","emacs","interpreter","microprocessor","org","org-babel","org-mode","python","repl","simulator","terminal","vim"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hemanta212.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-30T18:20:40.000Z","updated_at":"2023-11-08T04:22:38.000Z","dependencies_parsed_at":"2023-04-11T11:30:52.730Z","dependency_job_id":null,"html_url":"https://github.com/hemanta212/8085-simulator","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/hemanta212/8085-simulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemanta212%2F8085-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemanta212%2F8085-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemanta212%2F8085-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemanta212%2F8085-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hemanta212","download_url":"https://codeload.github.com/hemanta212/8085-simulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hemanta212%2F8085-simulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31703498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T21:17:31.016Z","status":"online","status_checked_at":"2026-04-12T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["8085","8085-interpreter","8085-simulator","emacs","interpreter","microprocessor","org","org-babel","org-mode","python","repl","simulator","terminal","vim"],"created_at":"2024-10-11T15:48:54.211Z","updated_at":"2026-04-12T03:31:51.711Z","avatar_url":"https://github.com/hemanta212.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"* 8085-Interpreter\n#+html: \u003ca href=\"https://github.com/hemanta212/8085-simulator/actions/workflows/main.yml\"\u003e\u003cimg src=\"https://github.com/hemanta212/8085-simulator/actions/workflows/main.yml/badge.svg\" /\u003e\u003c/a\u003e\n\nA simple exploratory interpreter with REPL experience. (Beginning learning purpose only)\n\n- For windows users, you can download and run the =.exe= file  from [[https://github.com/hemanta212/8085-simulator/releases/latest][releases page]].\n- Clone and run this repository,\n#+begin_src shell :eval never\n  git clone https://github.com/hemanta212/8085-simulator\n  python -m pip install loguru rich pyreadline\n  cd 8085-simulator\n  python main.py\n#+end_src\n\nType =help= and run the commands listed.\n\nFor detailed examples on available commands, see file [[file:usage_examples.org]].\n\n** Table of contents\n:PROPERTIES:\n:TOC:      :include siblings :depth 2\n:END:\n:CONTENTS:\n- [[#features][Features]]\n- [[#repl-mode][REPL Mode]]\n- [[#command-line-arguments][Command line arguments]]\n- [[#example-repl-workflow][Example Repl Workflow]]\n- [[#example-command-line-workflow][Example Command line Workflow]]\n  - [[#the-file-option--f][The file option (-f)]]\n  - [[#the-command-option--c][The command option (-c)]]\n  - [[#the-json-file-db-option--db][The json file db option (-db)]]\n  - [[#the-plainindirect-mode-option--i][The plain/indirect mode option (-i)]]\n  - [[#the-verbosity-logging-option--v][The verbosity logging option (-v)]]\n- [[#using-from-terminal-vim-and-emacs][Using From Terminal, Vim and Emacs]]\n  - [[#example-emacs-org-babel-config][Example Emacs Org babel config]]\n  - [[#emacs-8085-major-mode][Emacs 8085 major mode]]\n- [[#extensive-usage-examples][Extensive Usage Examples]]\n:END:\n\n** Features\n- [x] - Implement Registers and Memory\n- [x] - Implement Basic commands (ADD, ADI, SUB, SUI, MOV, MVI, STA, LDA)\n- [x] - Implement Xtended Register Pairs (LXI, M, LDAX)\n- [x] - Write a ob-8085 for emacs org-mode (babel)\n- [x] - Implement Flags (CY, Z, S)\n- [x] - Implement labels and jumps (Loops) [Commands: JC, JNC, JZ, JNZ)\n- [x] - Implement increment/decrements [INR, DCR]\n- [x] - Implement  Xtended increment/decrements [INX, DCX]\n- [x] - Implement basic commands (CMP/CPI, OUT)\n- [x] - Implement comments, empty lines, HLT(no-effect)\n- [x] - Release a pyinstaller executable\n- [ ] - Implement commands (ANI, ORI, RRC, STAX)\n- [ ] - ... ( a lot of commands)\n- [ ] - Implement proper 8-bit 16-bit type system and validation\n- [ ] - Implement a stacktrace in case of errors\n- [x] - Implement integration test and actions CI\n- [ ] - A pypi package\n- [-] - Write a major mode for emacs.\n\n** REPL Mode\n#+begin_src shell :exports both :results output\npython main.py\n#+end_src\n\n#+RESULTS:\n: Welcome to the 8085 emulator.\n: Type 'help' for a list of commands.\n: \u003e\u003e\u003e\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e help\n#+end_src\n#+begin_src shell :exports results :results output\necho \"help\" | python main.py -i\n#+end_src\n\n#+RESULTS:\n#+begin_example\nMOV - Move data from one register to another\nMVI - Move to immediate\nINR - Increment Register\nDCR - Decrement Register\nLXI - Load register pair immediate\nLDA - Load accumulator\nSTA - Store accumulator\nHLT - Halt\nADD - Add\nSUB - Subtract\nADI - Add Immediate\nSUI - Subtract Immediate\nCMP - Compare\nCPI - Compare Immediate\nANI - And Immediate with Accumulator\nORI - OR Immediate with Accumulator\nRRC - Rotate Right Accumulator\nLDAX - Load accumulator from register pair\nSTAX - Store accumulator to register pair\nINX - Incremented xtended register pairs\nDCX - Decrement xtended register pairs\nJZ - Jump If Zero\nJNZ - Jump If Not Zero\nJC - Jump If Carry\nJNC - Jump If Not Carry\nOUT - Out\n#+end_example\n\n** Command line arguments\nBeside repl, the interpreter can be entirely run from command line.\n#+begin_src shell :exports none :results none\n# Cleanup previous eval files if any (during the all eval C-c C-v b)\n  rm -f /tmp/pyassm-readme-01 /tmp/pyassm-readme-02\n#+end_src\n#+begin_src shell :exports both :results output :wrap example\n  python main.py --help\n#+end_src\n\n#+RESULTS:\n#+begin_example\n:8085 Interpreter:\n\nhelp | --help | -h: Display this message\n-i                : Run in indirect mode, dont display welcome msg and \u003e\u003e\u003e\nprompt\n-v \u003cd/i/w/e\u003e      : Verbosity option use (d,i,w,e) for (DEBUG, INFO, WARNING,\nERROR) resp.\n-db \u003cFILENAME\u003e    : Run in file db mode save and restore after each cmd from\nfile\n-f \u003cFILENAME\u003e     : Read command/commands from file\n-c \"cmd1;cmd2\"    : Run cmd directly, separate with \";\" for more than one\ncommands\n\nNOTE: In case of using multiple options, they need to be specified in order\nlisted above.\n#+end_example\n\nThe interpreter provides:\n- An option to run in raw plain mode without any welcome message or =\u003e\u003e\u003e= prompt through =-i= option.\n- An option to pass a file (containing commands line by line) to the interpreter to evaluate through =-f= option.\n- An option to save state after each command to a json file through  =-db= option.\n- An option to run commands in place through  =-c= option.\n- An option to customize the verbosity of logging messages through =-v= option.\n\n*NOTE*:\nIn case of using multiple options, they need to be specified in order,\n- =-i= , =-v=, =-db=, =-f=, =-c=\nProviding options otherwise will result in an error.\n\n** Example Repl Workflow\n*NOTE* Fore more extensive examples for each commands, see file [[file:usage_examples.org]].\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e inspect\n#+end_src\n#+begin_src shell :exports results :results output\necho \"inspect\" | python main.py -i\n#+end_src\n\n#+RESULTS:\n#+begin_example\nRegisters:\n\tA: 0x00\n\tB: 0x00\n\tC: 0x00\n\tD: 0x00\n\tE: 0x00\n\tH: 0x00\n\tL: 0x00\n\tM: 0x00\n\nMemory:\n\t0x1000: 0x2b\n\t0x1001: 0x34\n\t0x0000: 0x00\n\nFlags:\n\tcarry: 0\n\tauxillary_carry: 0\n\tzero: 0\n\tsign: 0\n#+end_example\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e MVI B 05H\n#+end_src\n#+begin_src shell :exports results :results output\necho \"MVI B 05H\" | python main.py -i -db /tmp/pyassm-readme-01\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e MVI C 05H\n#+end_src\n#+begin_src shell :exports results :results output\necho \"MVI C 05H\" | python main.py -i -db /tmp/pyassm-readme-01\n#+end_src\n\n#+RESULTS:\n: C -\u003e 05H\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e ADD B\n#+end_src\n#+begin_src shell :exports results :results output\necho \"ADD B\" | python main.py -i -db /tmp/pyassm-readme-01\n#+end_src\n\n#+RESULTS:\n: A -\u003e 00H + 05H -\u003e 05H\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e ADD C\n#+end_src\n#+begin_src shell :exports results :results output\necho \"ADD C\" | python main.py -i -db /tmp/pyassm-readme-01\n#+end_src\n\n#+RESULTS:\n: A -\u003e 05H + 05H -\u003e 0AH\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e STA 3322H\n#+end_src\n#+begin_src shell :exports results :results output\necho \"STA 3322H\" | python main.py -i -db /tmp/pyassm-readme-01\n#+end_src\n\n#+RESULTS:\n: 3322H -\u003e 0AH\n\n#+begin_src shell :eval never\n\u003e\u003e\u003e inspect\n#+end_src\n#+begin_src shell :exports results :results output\necho \"inspect\" | python main.py -i -db /tmp/pyassm-readme-01\n#+end_src\n\n#+RESULTS:\n#+begin_example\nRegisters:\n\tA: 0x0a\n\tB: 0x05\n\tC: 0x05\n\tD: 0x00\n\tE: 0x00\n\tH: 0x00\n\tL: 0x00\n\tM: 0x00\n\nMemory:\n\t0x1000: 0x2b\n\t0x1001: 0x34\n\t0x0000: 0x00\n\t0x3322: 0x0a\n\nFlags:\n\tcarry: 0\n\tauxillary_carry: 0\n\tzero: 0\n\tsign: 0\n#+end_example\n\n** Example Command line Workflow\n*** The file option (=-f=)\n#+begin_src shell :exports both :results output\n  echo \"MVI B 05H\" \u003e test.txt\n  echo \"MVI A 00H\" \u003e\u003e test.txt\n  python main.py -f test.txt\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n: A -\u003e 00H\n\n#+begin_src shell :exports none :results none\n# clean up\n  rm -f test.txt\n#+end_src\n\n*** The command option (=-c=)\n#+begin_src shell  :exports both :results output\n  python main.py -c \"MVI B 05H\"\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n\n#+begin_src shell :exports both :results output\n  python main.py -c \"MVI A 00H; MVI B 05H; ADD B\"\n#+end_src\n\n#+RESULTS:\n: A -\u003e 00H\n: B -\u003e 05H\n: A -\u003e 00H + 05H -\u003e 05H\n\n*** The json file db option (=-db=)\nSpecifying the file db option saves the state of interpreter to a json file and restores from it every time a *8085 command* is executed.\n\nThis is useful when trying to run multiple =-c= commans as a session.\n#+begin_src shell :exports both :results output\n  python main.py -db /tmp/pyassm-readme-02 -c \"MVI B 05H\"\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n\n#+begin_src shell :exports both :results output\n  python main.py -db /tmp/pyassm-readme-02 -c \"MVI A 00H; ADD B\"\n#+end_src\n\n#+RESULTS:\n: A -\u003e 00H\n: A -\u003e 00H + 05H -\u003e 05H\n\n#+begin_src shell :exports both :results output\n  python main.py -db /tmp/pyassm-readme-02 -c \"STA 5555H; inspect\"\n#+end_src\n\n#+RESULTS:\n#+begin_example\n5555H -\u003e 05H\nRegisters:\n\tA: 0x05\n\tB: 0x05\n\tC: 0x00\n\tD: 0x00\n\tE: 0x00\n\tH: 0x00\n\tL: 0x00\n\tM: 0x00\n\nMemory:\n\t0x1000: 0x2b\n\t0x1001: 0x34\n\t0x0000: 0x00\n\t0x5555: 0x05\n\nFlags:\n\tcarry: 0\n\tauxillary_carry: 0\n\tzero: 0\n\tsign: 0\n#+end_example\n\n*** The plain/indirect mode option (=-i=)\nThis is very useful for piping interactions to and from other applications.\nIt is also recommended to run in =-db= file mode for continuous session-like interaction.\n#+begin_src shell :exports both :results output\n  echo \"MVI B 05H\" | python main.py -i\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n\n#+begin_src shell :exports both :results output\n  echo \"MVI B 05H\\nADD B\" | python main.py -i\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n: A -\u003e 00H + 05H -\u003e 05H\n\n*** The verbosity logging option (=-v=)\nYou can customize the verbosity of logging messages by providing,\n- =d= : For =DEBUG= level\n- =e= : For =ERROR= level\n- =w= : For =WARNING= level\n- =i= : For =INFO= level\n\n#+begin_src shell\n  echo \"MVI B 05H\" | python main.py -i -v d\n#+end_src\n\n#+RESULTS:\n: B -\u003e 05H\n\n** Using From Terminal, Vim and Emacs\nThe command line options provided by interpreter allows it to be used through editors like Vim and Emacs.\nEither you can:\n- Use the =-f= option and write and execute using a temp buffer/file.\n- Use combination of =-c= and =-db= option to emulate a repl session.\n- Use combnation of =-i= and =-db= option to emulate a repl session.\n\n*** Example Emacs Org babel config\nWith some configuration, the interpreter can be made to work with Emacs' Org Mode using the =org-babel-eval= function.\nThis uses =-i= command option to write to the interpreter.\n\nPut this in your =init.el= file,\n#+begin_src emacs-lisp :eval never\n  (defcustom path-to-8085 \"~/dev/8085-interpreter/\"\n    \"Path to folder where 8085-interpreter was cloned\")\n\n  (defcustom org-babel-8085-command\n    (concat\n     \"python\"\n     (concat path-to-8085 \"/main.py\"))\n    \"Name of the command for executing 8085 interpreter.\")\n\n  (defun org-babel-execute:8085 (body params)\n    (let ((args (cdr (assoc :args params))))\n      (org-babel-eval\n       (concat\n        org-babel-8085-command\n        (if args  (concat \" -i \" args) \" -i \" ))\n       body)))\n\n  ;; Placeholder major mode, look below for more featured major mode\n  (define-derived-mode 8085-mode prog-mode \"8085\"\n     \"Major mode for 8085.\"\n     (setq-local comment-start \";\")\n     (setq-local comment-start-skip \";+[\\t ]*\"))\n#+end_src\n\n- The =path-to-8085= should be folder where you cloned this project.\n- The =org-babel-8085-command= should be the command to run the interpreter (eg python main.py),\n  - You could use =(concat path-to-8085 \"/.venv/bin/python\")= in place of \"=python=\"  if you use in-project virtual environments.\n\n*** Emacs 8085 major mode\n#+begin_src emacs-lisp :eval never\n    (require 'rx)\n    (defvar 8085-mode-map\n      (let ((map (make-sparse-keymap)))\n        map))\n\n  (defconst 8085--font-lock-defaults\n    (let (\n          (instructions '(\"MVI\" \"MOV\" \"ADD\" \"SUB\" \"ADI\"\n                          \"SUI\" \"JNZ\" \"JNC\" \"JZ\" \"JC\" \"LXI\"\n                          \"LXAD\" \"INR\" \"DCR\" \"INX\" \"DCX\" \"OUT\"\n                          \"HLT\" \"CPI\" \"CMP\" \"STA\" \"LDA\")))\n      `(((,(rx-to-string `(: (or ,@instructions))) 0 font-lock-keyword-face)\n      (\"\\\\([[:word:]]+\\\\):\" 1 font-lock-function-name-face)))))\n\n    (defvar 8085-mode-syntax-table\n    (let ((st (make-syntax-table)))\n      ;; - and _ are word constituents\n      (modify-syntax-entry ?_ \"w\" st)\n      (modify-syntax-entry ?- \"w\" st)\n\n      ;; add comments. lua-mode does something similar, so it shouldn't\n      ;; bee *too* wrong.\n      (modify-syntax-entry ?\\; \"\u003c\" st)\n      (modify-syntax-entry ?\\n \"\u003e\" st)\n      st))\n\n    (define-derived-mode 8085-mode prog-mode \"8085\"\n      \"Major mode for 8085.\"\n      (setq font-lock-defaults 8085--font-lock-defaults)\n      (setq-local comment-start \";\")\n      (setq-local comment-start-skip \";+[\\t ]*\")\n      (setq-local case-fold-search nil))\n#+end_src\n\nSave and restart your emacs (or execute each block with =C-x C-e=).\nThen you can use org mode to write block like:\n\n- Use =C-c C-c= to execute a given block.\n#+begin_example\n,#+begin_src 8085 :args -v d -db /tmp/8085-session1\nMVI B 80H\n,#+end_src\n#+end_example\n\n- For session-like use,\n#+begin_example\n,#+begin_src 8085 :args -v d -db /tmp/8085-session1\nMVI B 80H\n,#+end_src\n#+end_example\n\n- For verbose logging,\n#+begin_example\n,#+begin_src 8085 :args -v d -db /tmp/8085-session1\nMVI B 80H\n,#+end_src\n#+end_example\n\n** [[file:usage_examples.org][Extensive Usage Examples]]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemanta212%2F8085-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhemanta212%2F8085-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhemanta212%2F8085-simulator/lists"}