{"id":16572288,"url":"https://github.com/jonocarroll/rx86","last_synced_at":"2025-07-19T18:08:45.898Z","repository":{"id":71014109,"uuid":"440746939","full_name":"jonocarroll/rx86","owner":"jonocarroll","description":"Simulated x86 assembly processing","archived":false,"fork":false,"pushed_at":"2021-12-23T02:18:28.000Z","size":36,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T22:13:54.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","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/jonocarroll.png","metadata":{"files":{"readme":"README.Rmd","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":"2021-12-22T05:45:41.000Z","updated_at":"2022-07-28T05:09:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"8403bb2f-b848-4241-951a-3ba48a79c19b","html_url":"https://github.com/jonocarroll/rx86","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonocarroll/rx86","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Frx86","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Frx86/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Frx86/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Frx86/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonocarroll","download_url":"https://codeload.github.com/jonocarroll/rx86/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Frx86/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265982890,"owners_count":23859575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-11T21:27:01.872Z","updated_at":"2025-07-19T18:08:45.876Z","avatar_url":"https://github.com/jonocarroll.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# rx86\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nThe goal of rx86 is to provide a functional representation of x86 assembly \nand execute the instructions.\n\n## Installation\n\nYou can install the development version of rx86 from Github with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"jonocarroll/rx86\")\n```\n\n## Motivation\n\nSee [this](https://jcarroll.com.au/2021/12/23/adventures-in-x86-asm/) blogpost, but I wanted to be able to 'run' some x86 assembly code and \nwondered if I could do it entirely from R.\n\nA small, more general example, is to perform multiplication\n```{r example}\nlibrary(rx86)\n\n## load some asm instructions which store the \n## the numbers 167 and 28, multiplies them, \n## and stores the result in 0x22\nmult_asm \u003c- suppressWarnings(\n  readr::read_fwf(system.file(\"asm\", \"mult.asm\", package = \"rx86\"), \n                  col_types = \"ccc\",\n                  col_positions = readr::fwf_widths(c(3, 6, 20)))\n)\ncolnames(mult_asm) \u003c- c(\"addr\", \"bytecode\", \"instr\")\nprint(mult_asm)\n\n# create blank slate of memory and registers\nmem \u003c- create_mem(len = 64)\nregisters \u003c- create_reg()\n\nrunasm(mult_asm)\n\n# extract result from memory and convert to integer\nas.integer(mem[sanitize(0x22)])\n\n167*28\n```\n\nThis is detailed in `vignette(\"mult_code_petzold\", package = \"rx86\")`.\n\nWhat test is complete without a helloworld?\n```{r}\nhello_asm \u003c- suppressWarnings(\n  readr::read_fwf(system.file(\"asm\", \"helloworld.asm\", package = \"rx86\"), \n                  col_types = \"ccc\",\n                  col_positions = readr::fwf_widths(c(3, 3, 20)))\n)\ncolnames(hello_asm) \u003c- c(\"addr\", \"bytecode\", \"instr\")\nprint(hello_asm)\n\nmem \u003c- create_mem()\nregisters \u003c- create_reg()\n\nrunasm(hello_asm)\n```\n\nThis is detailed in `vignette(\"helloworld\", package = \"rx86\")`.\n\n## Inspiration\n\nAfter reading ['Code: The Hidden Language of Computer Hardware and Software'](https://en.wikipedia.org/wiki/Code:_The_Hidden_Language_of_Computer_Hardware_and_Software) by Charles Petzold - which does a fantastic job of describing \nthe journey from telegraph relays through to a working computer - I was reminded that \nI had once looked into some assembly for a puzzle, but never wrote up my findings.\n\nIn an effort to better understand the solution to that puzzle (and the way to get to it) I thought it would be neat to try to replicate some of the functionality in a language I'm more familiar with. The operations on data stored in memory are simple - move a value from here to there, add some values, ... so it made sense to me to \nsee if I could replicate that in a functional language.\n\nThis isn't something you would use to write asm, but it very well may help you understand what it's doing.\n\n## Limitations\n\nThe following is a non-exhaustive list of the known limitations of this package.\n\n* This was originally built to support a single use-case of solving the puzzle described in \n``vignette(\"dsd_ruxcon_challenge\", package = \"rx86\")` so only has support for the\nopcodes required for that. That covers a lot of possibilities, but if you need a \n`DIV` you're out of luck so far.\n* The operations supported do so _in spirit_ and are not exact reproductions of \nfunctionality - if this does something different to real asm, that's not too surprising.\n* This takes as input a `data.frame` of disassembled code. This has only been tested\nwith the output of \n```{bash, eval = FALSE}\nudcli -x file.hex\n```\nwith the `udis` tool from http://udis86.sourceforge.net/.\n* \n\n## Other R assemblers\n * [c64](https://github.com/coolbutuseless/r64) - a c64/6502 assembler\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Frx86","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonocarroll%2Frx86","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Frx86/lists"}