https://github.com/stuarthayhurst/lmc-simulator
Assemble and execute Little Man Computer assembly
https://github.com/stuarthayhurst/lmc-simulator
assembler assembly little-man-computer
Last synced: about 2 months ago
JSON representation
Assemble and execute Little Man Computer assembly
- Host: GitHub
- URL: https://github.com/stuarthayhurst/lmc-simulator
- Owner: stuarthayhurst
- License: mit
- Created: 2023-03-28T22:12:38.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2026-04-23T18:35:39.000Z (2 months ago)
- Last Synced: 2026-04-23T20:23:02.272Z (2 months ago)
- Topics: assembler, assembly, little-man-computer
- Language: C++
- Homepage:
- Size: 122 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## lmc-simulator
- Assemble and execute assembly of the [Little Man Computer](https://en.wikipedia.org/wiki/Little_Man_Computer) instruction set
- Additionally supports comments starting with '`#`' or '`//`'
## Requirements:
- A compiler supporting `c++-20`
- Override the default by setting the `CXX` environment variable, if required
## Building:
- `make`: Builds the simulator
- Supports multiple threads with `-j[THREAD COUNT]`
- Use `make -j$(nproc)` to build with all available threads
- `make debug`: Builds the simulator with `DEBUG=true`
- `make clean`: Removes the compiled simulator, if present
- `DEBUG=[true/false]`: Environment variable to enable debug support
- Includes debug symbols, retains the frame pointer and uses sanitisers
- `BUILD_DIR`: Environment variable to configure built object output
## Usage:
- `./simulator [FILE] [MEMORY SIZE]`
- For example, `./simulator programs/power.asm`
- Or to limit the memory size to 50, `./simulator programs/power.asm 50`
- Set `DEBUG="true"` as an environment variable, to enable debug output
- `DEBUG="true" ./simulator [FILE]`
## Sample programs:
- In order of complexity, some sample programs are kept in `programs/`:
- `multiply.asm`: Multiply 2 inputs together
- `modulus.asm`: Carry out modular division between 2 inputs
- `triangular.asm`: Output the first `n` triangular numbers
- `fibonacci.asm`: Output the first `n` terms of the Fibonacci sequence
- `gcd.asm`: Output the greatest common divisor between 2 inputs
- `power.asm`: Raise the first input to the power of the second
- `iteration.asm`: Iterate over a group of addresses
- `quine.asm`: Iterate over the program's instructions to print its own code
- `binary.asm`: Convert an integer from input into 8-bit binary
- `leapyear.asm`: Check if a year from 1 to 999 was a leap year
## Contributing:
- Feel free to submit pull requests!
- Contributed code must fit the style of the codebase so far
- Sample assembly is also welcome, as long as it's under `programs/`