diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index eb01f8b2..d5178dc4 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -22,7 +22,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build Linux run: make CFLAGS+=-Werror debug @@ -33,7 +33,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run Makefile shell: powershell @@ -47,7 +47,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build MacOS run: make CFLAGS+=-Werror debug diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 05e3263e..69a6086d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/compilation_test.yml b/.github/workflows/compilation_test.yml index 42546b1e..fd75a303 100644 --- a/.github/workflows/compilation_test.yml +++ b/.github/workflows/compilation_test.yml @@ -20,7 +20,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Runs a single command using the runners shell - name: compile the project @@ -49,7 +49,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Compile memeasm shell: powershell @@ -71,7 +71,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 # Runs a single command using the runners shell - name: compile the project diff --git a/.github/workflows/compile_and_run_test.yml b/.github/workflows/compile_and_run_test.yml index 57394f4a..2cb06856 100644 --- a/.github/workflows/compile_and_run_test.yml +++ b/.github/workflows/compile_and_run_test.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Compile the project run: make debug @@ -30,7 +30,7 @@ jobs: runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Compile memeasm shell: powershell @@ -50,7 +50,7 @@ jobs: runs-on: macos-11 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Compile the project run: make debug diff --git a/.github/workflows/create_installers.yml b/.github/workflows/create_installers.yml index ea27a2c7..ff42b10f 100644 --- a/.github/workflows/create_installers.yml +++ b/.github/workflows/create_installers.yml @@ -13,10 +13,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - - name: Install mingw-w64 - run: sudo apt-get install mingw-w64 + - uses: actions/checkout@v3 - name: Install nfpm run: | @@ -37,22 +34,13 @@ jobs: cd .. - name: Archive debian installer - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: debian-installer - path: memeassembly_${{ github.event.inputs.version }}_amd64.deb + name: memeasm_${{ github.event.inputs.version }}_amd64.deb + path: memeasm_${{ github.event.inputs.version }}_amd64.deb - name: Archive rpm installer - uses: actions/upload-artifact@v2 - with: - name: rpm-installer - path: memeassembly-${{ github.event.inputs.version }}.x86_64.rpm - - - name: Compile for Windows - run: make windows - - - name: Upload Windows executable - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: memeasm.exe - path: memeasm.exe \ No newline at end of file + name: memeasm-${{ github.event.inputs.version }}.x86_64.rpm + path: memeasm-${{ github.event.inputs.version }}.x86_64.rpm diff --git a/.github/workflows/publish-aur.yml b/.github/workflows/publish-aur.yml index 58e7a6db..46a7a439 100644 --- a/.github/workflows/publish-aur.yml +++ b/.github/workflows/publish-aur.yml @@ -3,26 +3,51 @@ name: Publish to AUR on: release: types: [published] + workflow_dispatch: + inputs: + version: + description: 'Repository Tag (without v, e.g. 1.6)' + required: true + pkgrel: + required: true + default: "1" + jobs: aur-publish: runs-on: ubuntu-latest - steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Replace VERSION_STRING in PKGBUILD file with parameter - run: sed -i 's/VERSION_STRING/${GITHUB_REF:1}/g' PKGBUILD + if: ${{ github.event_name == 'release' }} + run: sed -i 's/VERSION_STRING/${GITHUB_REF:11}/g' PKGBUILD + + - name: Replace VERSION_STRING in PKGBUILD file with parameter + if: ${{ github.event_name == 'workflow_dispatch' }} + run: sed -i 's/VERSION_STRING/${{ github.event.inputs.version }}/g' PKGBUILD - name: Replace PKGREL in PKGBUILD file with parameter + if: ${{ github.event_name == 'release' }} run: sed -i 's/PKGREL/1/g' PKGBUILD + - name: Replace PKGREL in PKGBUILD file with parameter + if: ${{ github.event_name == 'workflow_dispatch' }} + run: sed -i 's/PKGREL/${{ github.event.inputs.pkgrel }}/g' PKGBUILD + + - name: Replace 256SUM in PKGBUILD file with parameter + if: ${{ github.event_name == 'release' }} + run: | + wget https://github.com/${{ github.repository }}/archive/$GITHUB_REF.tar.gz + export CHECKSUM= + sed -i "s/256SUM/$(sha256sum $GITHUB_REF.tar.gz | cut -d " " -f 1)/g" PKGBUILD + - name: Replace 256SUM in PKGBUILD file with parameter + if: ${{ github.event_name == 'workflow_dispatch' }} run: | - sudo apt-get install wget - wget https://github.com/kammt/MemeAssembly/archive/refs/tags/$GITHUB_REF.tar.gz - sed -i 's/256SUM/$(sha256sum $GITHUB_REF.tar.gz | cut -d " " -f 1)/g' PKGBUILD + wget https://github.com/${{ github.repository }}/archive/refs/tags/v${{ github.event.inputs.version }}.tar.gz + sed -i "s/256SUM/$(sha256sum v${{ github.event.inputs.version }}.tar.gz | cut -d " " -f 1)/g" PKGBUILD - name: Output PKGBUILD for debugging purposes run: cat PKGBUILD diff --git a/PKGBUILD b/PKGBUILD index 230a661d..54d8d7e4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -13,5 +13,5 @@ sha256sums=('256SUM') package() { cd "MemeAssembly-$pkgver" - make DESTDIR="$pkgdir/usr/local/bin" install + make DESTDIR="$pkgdir" install } diff --git a/README.md b/README.md index 4548c629..b2149539 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,19 @@ To do so, insert this code block into your ReadMe file: \ ## Contributing Contributions to this repository are welcome! Especially ideas for new (and hopefully idiotic) commands. To add a new command, either create an issue with the tag "new-command" or add it yourself and create a pull-request. +### How to add new commands? +This Is No Kinder Spiel, Old Bean! + +So, you reckon you've got the moxie to add a new command, eh? Brilliant! Here's the plan: + +1. **Command Crafting:** First, pop over to `compiler/compiler.c` and have a butcher's at the `commandList` array. Once you've spotted it, add your brand spanking new command to the squad. + +2. **The Count-Up:** Now that your new command is showing its colours, you'll need to keep the books straight. Duck into `compiler/commands.h` and notch up the `NUMBER_OF_COMMANDS` by the number of new commands you've added. Keeping tally matters! + +3. **Fingers Crossed:** Done everything by the book? Now cross your fingers, touch wood, and maybe toss a coin into the wishing well. You've played your hand, now it's time to let the code fairies sprinkle their magic! + +*Note: The pull requests should be made to the `develop` branch and not to the `main` branch. Failure to do so results in a bonk from the devs.* + ### Current Contributors: ![GitHub Contributors Image](https://contrib.rocks/image?repo=kammt/MemeAssembly) diff --git a/compiler/commands.h b/compiler/commands.h index e3b8c4f4..0f4df2b9 100644 --- a/compiler/commands.h +++ b/compiler/commands.h @@ -25,7 +25,7 @@ along with MemeAssembly. If not, see . #include #include -#define NUMBER_OF_COMMANDS 46 +#define NUMBER_OF_COMMANDS 60 #define MAX_PARAMETER_COUNT 2 #define OR_DRAW_25_OPCODE NUMBER_OF_COMMANDS - 2; diff --git a/compiler/compiler.c b/compiler/compiler.c index b19b8f1c..fd575dbc 100644 --- a/compiler/compiler.c +++ b/compiler/compiler.c @@ -84,6 +84,34 @@ const struct command commandList[NUMBER_OF_COMMANDS] = { .analysisFunction = NULL, .translationPattern = "pop {0}" }, + { + .pattern = "knock knock, who's there? {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG | PARAM_DECIMAL}, + .analysisFunction = NULL, + .translationPattern = "mov rax, [rip + {0}]" + }, + { + .pattern = "why don't you come on in, {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG | PARAM_DECIMAL}, + .analysisFunction = NULL, + .translationPattern = "mov [rip + {0}], rax" + }, + { + .pattern = "big brain time {p} {p}", + .usedParameters = 2, + .allowedParamTypes = {PARAM_REG, PARAM_REG | PARAM_DECIMAL}, + .analysisFunction = NULL, + .translationPattern = "mov [rip + {0}], {1}" + }, + { + .pattern = "execute order 66 {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG | PARAM_DECIMAL}, + .analysisFunction = NULL, + .translationPattern = "mov rax, 66\n\tmov [rip + {0}], rax" + }, ///Logical Operations { @@ -117,6 +145,20 @@ const struct command commandList[NUMBER_OF_COMMANDS] = { .analysisFunction = NULL, .translationPattern = "mov {0}, {1}" }, + { + .pattern = "I don't feel so good", + .usedParameters = 0, + .analysisFunction = NULL, + .translationPattern = "xor rax, rax\n\txor rbx, rbx\n\txor rcx, rcx\n\txor rdx, rdx\n\txor rsi, rsi\n\txor rdi, rdi\n\txor rbp, rbp\n\txor rsp, rsp\n\txor r8, r8\n\txor r9, r9\n\txor r10, r10\n\txor r11, r11\n\txor r12, r12\n\txor r13, r13\n\txor r14, r14\n\txor r15, r15" + }, + { + .pattern = "just a little switcheroo {p} {p}", + .usedParameters = 2, + .allowedParamTypes = {PARAM_REG, PARAM_REG}, + .analysisFunction = NULL, + .translationPattern = "xor {0}, {1}\nxor {1}, {0}\nxor {0}, {1}" + }, + ///Arithmetic operations { @@ -274,6 +316,12 @@ const struct command commandList[NUMBER_OF_COMMANDS] = { .analysisFunction = NULL, .translationPattern = ".LSamePicture_{F}:" }, + { + .pattern = "deja vu", + .usedParameters = 0, + .analysisFunction = NULL, + .translationPattern = "jmp main" + }, ///IO-Operations { @@ -376,6 +424,47 @@ const struct command commandList[NUMBER_OF_COMMANDS] = { .analysisFunction = NULL, .translationPattern = "syscall" }, + { + .pattern = "why are we still here, just to suffer", + .usedParameters = 0, + .analysisFunction = NULL, + .translationPattern = "mov eax, 0\n\tidiv eax" + }, + { + .pattern = "you're in the wrong neighbourhood {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG64 | PARAM_REG32 | PARAM_REG16}, + .analysisFunction = NULL, + .translationPattern = "rdrand {0}\n\tjmp {0}" + }, + { + .pattern = "stop, you violated the law", + .usedParameters = 0, + .analysisFunction = NULL, + .translationPattern = "hlt" + }, + { + .pattern = "into the multiverse {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG64 | PARAM_REG32 | PARAM_REG16}, + .analysisFunction = NULL, + .translationPattern = "mov ecx, {0}\nmultiverse:\nadd ecx, ecx\nsub ecx, 2\ncmp ecx, 0\njnz multiverse\ninc ecx\ndec ecx\nmov {0}, ecx\npushad\npopad\nmov eax, 2\ndiv eax" + }, + { + .pattern = "you're invited to suffer {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG64 | PARAM_REG32 | PARAM_REG16}, + .analysisFunction = NULL, + .translationPattern = "mov eax, {0}\nsuffer:\ncmp eax, 666\nje end_suffer\nadd eax, 1\njmp suffer\nend_suffer:\npush eax\npop eax\nxor eax, eax\ninc eax\nadd eax, 2\ndec eax\ndec eax\nmov {0}, eax" + }, + { + .pattern = "hollup, let him cook {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG64 | PARAM_REG32 | PARAM_REG16}, + .analysisFunction = NULL, + .translationPattern = "mov eax, 0\nmov ebx, 0\nmov ecx, 0\ncook:\ninc eax\ninc ebx\ninc ecx\nmov edx, eax\ncmp edx, {0}\njne cook\n" + }, + ///Debug commands { @@ -384,6 +473,13 @@ const struct command commandList[NUMBER_OF_COMMANDS] = { .analysisFunction = NULL, .translationPattern = "int3" }, + { + .pattern = "I'm feeling lucky {p}", + .usedParameters = 1, + .allowedParamTypes = {PARAM_REG | PARAM_DECIMAL}, + .analysisFunction = NULL, + .translationPattern = "int {0}" + }, //Insert commands above this one { .pattern = "or draw 25", diff --git a/nfpm/nfpm.yaml b/nfpm/nfpm.yaml index e23c1da5..bb55f521 100644 --- a/nfpm/nfpm.yaml +++ b/nfpm/nfpm.yaml @@ -1,7 +1,7 @@ # # check https://nfpm.goreleaser.com/configuration for detailed usage # -name: "memeassembly" +name: "memeasm" arch: "amd64" platform: "linux" version: VERSION_STRING diff --git a/nfpm/postremove.sh b/nfpm/postremove.sh index 706874b3..c36d4b42 100755 --- a/nfpm/postremove.sh +++ b/nfpm/postremove.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo make DESTDIR=$(dirname $(which memeasm)) uninstall \ No newline at end of file +sudo make uninstall