-
Notifications
You must be signed in to change notification settings - Fork 0
skpn/corewar
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a reverse engineering of a pseudo compiler and CPU that are used to run a basic version of the classic programming game 'Corewar'. The reference execs are in the resource folder, the reverse-engineered ones are generated by the Makefiles. In this game, champions coded in ASM are loaded in a malloc'ed memory zone and made to fight until only one remains 'alive'. The core of the concept is that the virtual machine creates processes that will continuously read the memory of the arena and eexecutes any valid command code. A process has access to a small private memory of 16 registers, and has a program counter (PC) that allows it to know where it is in the arena. One of the commands is the 'live' command. When a process executes the live command, it declares that the champion corresponding to the number in its first register is 'alive' (if there is no matching champion no one is declared alive). The virtual machine will check at a set interval which champion has been declared alive. If a champion is not declared alive at least once between two verifications, it is eliminated (if by chance its champion number ends up in the first register of a process that then executes a live command, the champion 'ressuscitates'). At the start of the game one process is set at the start of each champion, and will execute that champion's code ; in time, the champions will fork (create new processes), overwrite each other, steal each other's processes (write their champion number in the first register of a process they did not spawn, so that if that process executes the live command they will benefit from it instead of the parent champion). You can find examples of champions in checker/champs/s_files, a pseudo-assembly compiler in the asm folder, and a virtual machine in the vm folder. The resource folder contains the reference executables that we had to rreverse engineer for this project, and the checker folder contains numerous valid and invalid champions, and two bash scripts that check the results of our executables against that of the reference ones.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published