https://github.com/andreiglesias/corewar
Development of a Virtual Computer, an Assembler and a Disassembler for the programming game Corewar.
https://github.com/andreiglesias/corewar
assembler assembly-language c corewar disassembler low-level-programming
Last synced: 3 months ago
JSON representation
Development of a Virtual Computer, an Assembler and a Disassembler for the programming game Corewar.
- Host: GitHub
- URL: https://github.com/andreiglesias/corewar
- Owner: AndreIglesias
- License: gpl-3.0
- Created: 2020-09-01T11:18:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-15T09:56:32.000Z (about 3 years ago)
- Last Synced: 2025-05-07T01:42:41.916Z (8 months ago)
- Topics: assembler, assembly-language, c, corewar, disassembler, low-level-programming
- Language: C
- Homepage:
- Size: 40.6 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A virtual Computer, an Assembler and a Disassembler for the programming game Corewar.
---
Introduction •
Virtual Computer •
Assembler •
Disassembler •
Bonus Features •
Installation •
License

# Introduction
Core War was inspired by a malicious virus written in the 80’s. To deal with the self-replicating virus, a white hat hacker invented Reaper. It was a virus designed to spread and eliminate the malware. He fought fire with fire.
This inspired A. K. Dewdney to coin the idea for Core War.
The idea was simple. You compete by designing viruses to overtake a computer. You win by protecting your own program and overwriting your opponent's programs. This is all happening on a virtual computer. Think, a simple computer within your computer.
# Virtual Computer
### VM General Structure:
[](https://github.com/AndreIglesias/Corewar/blob/master/docs/img/doc1.png)
[Reference](https://www.mathcs.emory.edu/~cheung/Courses/170/Syllabus/01/intro-computer2.html)
The loading of the **champions** and the **enumeration** of each player happens in the command line.
It’s important to remember that the **last player** will have the **first process** in the order of *execution*.
### VM Usage:

### Champions loaded without any option:

### Dumping memory at given cycle:

## Ncurse's Display

### Loading champions
The champions are loaded within the memory so that they can space out evenly their entry points.
At startup, each champion have their initial process at their respective entry point.

### Processes Table
The **number** (*id*) of the player is generated by the machine or specified at launch, and is given to the champions via the **r1 registry** of their first process at startup.

So even if the champion has *no instructions*, it will be able to participate as a contestant with the help of the **initial process** and the registry **r1** which has its player’s id.
# Assembler
The **assembler** (*asm*) translates the champion's code to bytecode.
### zork.s:

### champion's header and the Magic Number:

### champion's instructions in bytecode:

### asm with the -v option
The **asm** translates the champion into a *.cor bytecode file*, as usual, but also displays in the standard output, the **syntax table** with translation of each instruction to the right.

## Disassembler
The **disassembler** takes a *.cor bytecode file* and translates into a *.s assembly file*.
### Assembling a disassembled zork.cor:

## Bonus Features
1. (vm) ncurse’s interface visualizer
2. (vm) verbose and formatted output (-v)
3. (asm) a detailed syntax table display (-v)
4. (asm) beautiful error message when assembling
+ with line numbers, and a cursor to show where is the error
+ differentiating between **lexical** and **syntactical** error.
+
+
5. (other) disassembler
6. (other) org documentation
+
# Installation
```bash
# Clone this repository
$ git clone --recurse-submodules https://github.com/AndreIglesias/Corewar
# Go into the repository
$ cd Corewar
# Compile the project
$ make
```
## License
> [GPL v3.0](https://github.com/AndreIglesias/Corewar/blob/master/LICENSE) ·
> [@AndreIglesias](https://github.com/AndreIglesias)