{"id":20396829,"url":"https://github.com/tangerinearc/simple-assembler-n-emulator","last_synced_at":"2025-03-05T01:12:20.540Z","repository":{"id":261086207,"uuid":"883162436","full_name":"tangerineArc/SIMPLE-Assembler-n-Emulator","owner":"tangerineArc","description":"two-pass assembler and emulator based on a SIMPLE instruction set","archived":false,"fork":false,"pushed_at":"2024-11-17T09:42:13.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-05T01:12:17.618Z","etag":null,"topics":["ansi-c","assembly-language","emulator","two-pass-assembler"],"latest_commit_sha":null,"homepage":"","language":"C","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/tangerineArc.png","metadata":{"files":{"readme":"README.md","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":"2024-11-04T13:39:25.000Z","updated_at":"2024-11-17T09:42:16.000Z","dependencies_parsed_at":"2025-01-15T10:31:22.890Z","dependency_job_id":"8c5bc597-8400-4687-8402-026d3abfe241","html_url":"https://github.com/tangerineArc/SIMPLE-Assembler-n-Emulator","commit_stats":null,"previous_names":["tangerinearc/microarchassembleremulator","tangerinearc/simpleassembleremulator","tangerinearc/simple-assembler-n-emulator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangerineArc%2FSIMPLE-Assembler-n-Emulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangerineArc%2FSIMPLE-Assembler-n-Emulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangerineArc%2FSIMPLE-Assembler-n-Emulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tangerineArc%2FSIMPLE-Assembler-n-Emulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tangerineArc","download_url":"https://codeload.github.com/tangerineArc/SIMPLE-Assembler-n-Emulator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241945526,"owners_count":20046869,"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":["ansi-c","assembly-language","emulator","two-pass-assembler"],"created_at":"2024-11-15T04:09:48.543Z","updated_at":"2025-03-05T01:12:20.532Z","avatar_url":"https://github.com/tangerineArc.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SIMPLE Assembler \u0026 Emulator\n\nThe project consists of a two-pass assembler to convert assembly-language programs, written as per the provided SIMPLE instruction-set, into executable machine-code.  \nThe machine-code can then be executed by an emulator.\n\n## Setup Instructions\nClone this repository:\n```\ngit clone https://github.com/tangerineArc/Simple-Assembler-n-Emulator.git\n```\n\u003e [!NOTE]\n\u003e If your system (particularly Windows and macOS) does not have `make` installed, install `make` first before proceeding.\n\u003e\n\u003e Also, ensure that `gcc` is installed\n\nCompile `asm.c`.\n```\n$ make assembler\n```\nOn successful compilation `assemble.exe` will be created in the current directory.\n\nCompile `emu.c`.\n```\n$ make emulator\n```\nOn successful compilation `emulate.exe` will be created in the current directory.\n\n## Usage Instructions\nAssemble an assembly program. On successful assembly, `machine-code.out` and `listing.lst` will be created in the current directory.\n```\n$ ./assemble.exe file-path\n```\nExecute the program using emulator.\n```\n$ ./emulate.exe -option object-file-path\n```\nTo get a list of available emulator options:\n```\n$ ./emulate.exe -man\n```\n\n## Project Filesystem Explanation\nBelow is a list of all the files and directories that the project contains:\n- `asm.c` - assembler source-code\n- `emu.c` - emulator source-code\n- `/headers` - contains header files\n  - `dataStructures.h`\n  - `utils.h`\n- `/lib` - contains essential functions and data-structure implementations\n  - `dataStructures.c`\n  - `utils.c`\n- `claims.txt` - contains claims regarding the project\n- `/bubbleSort` - contains assembly program, console output as log-file, listing, object-file for bubble-sort program\n- `/sampleTests` - contains provided sample programs, console outputs as log-files, listings, object-files\n- `/additionalTests` - contains additional assembly programs, console output as log-files, listings, object-files\n\n## Assembly Language\nThe assembly language is for a machine with four registers:\n- Two registers: **A** \u0026 **B**, arranged as an internal stack\n- A program counter: **PC**\n- A stack pointer: **SP**\n\nThese registers are 32 bits in size.  \nThe encoding uses the bottom 8 bits for opcode and the upper 24 bits for operand.  \n\nAs with most assembly languages, this is line-based i.e. one statement per line.  \nComments begin with a '**;**' and anything on the line after the '**;**' is ignored.  \n\nBlank lines and lines containing only a comment are permitted and ignored.  \nWhite space (including tabs) are permitted at the beginning of a line and ignored.\n\nInstructions have either no operands or a single operand. The operand is a signed two's complement value.  \nAn operand is either a label or a number. The number can be decimal, hexadecimal or octal.\n\nLabel definitions consist of the label name followed by a '**:**', and an optional statement.  \nThere is not necessarily a space between the '**:**' and the statement.\n\nA label use is just the label name. A valid label name is an alphanumeric string beginning with a letter.  \nFor branch instructions label use should calculate the branch displacement.  \nFor non-branch instructions, the label value should be used directly.\n\n## SIMPLE Instruction Set\nThe instruction semantics do not show the incrementing of the **PC** to the next instruction.  \nThis is implicitly performed by each instruction before the actions of the instruction are done. \n\n| Mnemonic | Opcode | Operand | Formal Specification | Description |\n| --- | --- | --- | --- | --- |\n| data |  | value | | reserve a memory location, initialized to the value specified |\n| ldc | 0 | value | B := A; A := value; | load accumulator with the value specified |\n| adc | 1 | value | A := A + value; | add the value specified to the accumulator |\n| ldl | 2 | offset | B := A; A := memory[SP + offset]; | load local |\n| stl | 3 | offset | memory[SP + offset] := A; A := B; | store local |\n| ldnl | 4 | offset | A := memory[A + offset]; | load non-local |\n| stnl | 5 | offset | memory[A + offset] := B; | store non-local |\n| add | 6 | | A := B + A; | addition |\n| sub | 7 | | A := B - A; | subtraction |\n| shl | 8 | | A := B \u003c\u003c A; | shift left |\n| shr | 9 | | A := B \u003e\u003e A; | shift right |\n| adj | 10 | value | SP := SP + value; | adjust SP |\n| a2sp | 11 | | SP := A; A := B | transfer A to SP |\n| sp2a | 12 | | B = A; A := SP; | transfer SP to A |\n| call | 13 | offset | B := A; A := PC; PC := PC + offset; | call procedure |\n| return | 14 | | PC := A; A := B; | return from procedure |\n| brz | 15 | offset | if A == 0 then PC := PC + offset; | if accumulator is zero, branch to specified offset |\n| brlz | 16 | offset | if A \u003c 0 then PC := PC + offset; | if accumulator is less than zero, branch to specified offset |\n| br | 17 | offset | PC := PC + offset; | branch to specified offset |\n| HALT | 18 | | | stop the emulator; not a 'real' instruction; needed to tell emulator when to finish |\n| SET | | value | | set the label on current line to the specified value; is a pseudo-instruction |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangerinearc%2Fsimple-assembler-n-emulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftangerinearc%2Fsimple-assembler-n-emulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangerinearc%2Fsimple-assembler-n-emulator/lists"}