Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/compilation_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/compile_and_run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: windows-2019

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Compile memeasm
shell: powershell
Expand All @@ -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
Expand Down
26 changes: 7 additions & 19 deletions .github/workflows/create_installers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
name: memeasm-${{ github.event.inputs.version }}.x86_64.rpm
path: memeasm-${{ github.event.inputs.version }}.x86_64.rpm
37 changes: 31 additions & 6 deletions .github/workflows/publish-aur.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ sha256sums=('256SUM')
package() {
cd "MemeAssembly-$pkgver"

make DESTDIR="$pkgdir/usr/local/bin" install
make DESTDIR="$pkgdir" install
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion compiler/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ along with MemeAssembly. If not, see <https://www.gnu.org/licenses/>.
#include <stdlib.h>
#include <stdbool.h>

#define NUMBER_OF_COMMANDS 46
#define NUMBER_OF_COMMANDS 60
#define MAX_PARAMETER_COUNT 2

#define OR_DRAW_25_OPCODE NUMBER_OF_COMMANDS - 2;
Expand Down
96 changes: 96 additions & 0 deletions compiler/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}]"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not going to work with a register (also on other occasions).

},
{
.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}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. You might want to make .text rwx, too..

},
{
.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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: MemeASM only requires a main-function when you create an executable. When you create an assembly file (-S) or an object file (-O), using this command would result in the generated code having a potentially undefined reference (Since you could link it with something that defines start, but not main)

},

///IO-Operations
{
Expand Down Expand Up @@ -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}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jmp r/m only supports 16/64 bit opsize, and 16-bit opsize is useless as Linux by default refuses to map to the lowest 64 kiB.

},
{
.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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushad/popad don't exist in 64-bit mode.

},
{
.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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push r32 doesn't exist in 64-bit mode...

},
{
.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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only works with REG32.

},


///Debug commands
{
Expand All @@ -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}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only works with integer between 0 and 255.

},
//Insert commands above this one
{
.pattern = "or draw 25",
Expand Down
2 changes: 1 addition & 1 deletion nfpm/nfpm.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# check https://nfpm.goreleaser.com/configuration for detailed usage
#
name: "memeassembly"
name: "memeasm"
arch: "amd64"
platform: "linux"
version: VERSION_STRING
Expand Down
2 changes: 1 addition & 1 deletion nfpm/postremove.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
sudo make DESTDIR=$(dirname $(which memeasm)) uninstall
sudo make uninstall