{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Using RiscEmu from Python\n", "\n", "Here is how you can run some assembly through RiscEmu from Python.\n", "\n", "This example is using [this fibonacci assembly](examples/fibs.asm)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from riscemu import RunConfig, UserModeCPU, RV32I, RV32M, AssemblyFileLoader\n", "\n", "cfg = RunConfig(debug_instruction=False, verbosity=50)\n", "cpu = UserModeCPU((RV32I, RV32M), cfg)\n", "\n", "loader = AssemblyFileLoader.instantiate('examples/fibs.asm', [])\n", "cpu.load_program(loader.parse())\n", "\n", "cpu.launch(cpu.mmu.programs[-1], True)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.8" } }, "nbformat": 4, "nbformat_minor": 4 }