-
Notifications
You must be signed in to change notification settings - Fork 0
Resources
The Corewar project page provides links for downloading the following files:
In this archive you can find the compiled executable file of the virtual machine corewar
, the compiled compiler program asm
, as well as many champions in the form .s
and .cor
files.
The project assignment says that the program asm
translates code from the assembly language from the .s
file into byte-code, which should be placed into a file with the extension .cor
.
But in fact, the provided program does not pay any attention to the file extensions. It only searches for the last dot in the name and replaces all further contents with an extension .cor
.
The following situations, which are not errors in the usual sense, but still violate the declared workflow, are possible:
$ ./asm batman.cor
Writing output program to batman.cor
$ ./asm batman
Writing output program to .cor
$ ./asm dc.heroes/batman
Writing output program to dc.cor
Also, the provided program does not limit the number of champions accepted for processing.
You can specify a lot of files with a variety of extensions as arguments at one time. True, only the last of them will be processed:
$ ./asm ant-man.s iron_man.s batman.s
Writing output program to batman.cor
asm
ignores all other arguments:
$ ./asm --undefined-flag incorrect_file.s batman.s
Writing output program to batman.cor
Since such behaviour is not described in the text of the task, you can limit the number of accepted arguments to just one file, which must have an extension .s
.
This will make the work asm
more transparent and eliminate the above vulnerabilities in workflow.
By the way, the virtual machine does not check incoming files for the
.cor
extension.Extension check could still be added to comply with a single style of behaviour for all system components.
There are also problems with the provided examples of champions.
Unfortunately, not all files were written correctly. Therefore, the program asm
will not be able to translate some of them into bytecode and will give an error.
There will be no problems with the files from the folder 'champs/examples', but you will have to verify other files personally.
The file op.c
contains a structure that describes each operation defined in assembly language.
The data given in this structure can be overwritten in any form convenient for us and placed in the project, no restrictions have been established.
The file op.h
contains important preprocessor constants that determine the parameters of the virtual machine, as well as assembler syntax.
This file should be handled more carefully and included in the project. Consider making only the most necessary changes, because its' availability is one of the conditions for participation in the project “Corewar Championship”:
It will be executed on our own virtual machine, so the configuration will be the one you will describe in your file
op.h
that will be attached.
The necessary changes mean compliance with Norm.
If you don't plan to particiate in the championship, then you shouldn't worry about the fate of the file op.h
.