Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

New memeasm commands#83

Open
babyygemperor wants to merge 17 commits intokammt:developfrom
babyygemperor:main
Open

New memeasm commands#83
babyygemperor wants to merge 17 commits intokammt:developfrom
babyygemperor:main

Conversation

@babyygemperor
Copy link
Copy Markdown

Pull Request Changelog

Alright, let's take a quick squiz at what I've done in this pull request.

  1. "knock knock, who's there? {p}" - This function is asking the universe for a value at a certain memory location. It moves the value at the address pointed to by {p} into rax.

  2. "why don't you come on in, {p}" - This function moves the value from rax into the memory location pointed to by {p}.

  3. "big brain time {p} {p}" - This moves the value of the second parameter {1} into the memory location pointed to by the first parameter {0}.

  4. "execute order 66 {p}" - This function moves the number 66 into rax, and then moves rax into the memory location pointed to by {p}.

  5. "I don't feel so good" - This function sets all registers to zero.

  6. "just a little switcheroo {p} {p}" - This one swaps the contents of the two registers {0} and {1} using only logical operators.

  7. "deja vu" - This function jumps back to the start.

  8. "why are we still here, just to suffer" - This function generates a divide-by-zero error and crash the program.

  9. "you're in the wrong neighbourhood {p}" - Generates a random number and jumps to that address.

  10. "stop, you violated the law" - This function stops the program execution.

  11. "into the multiverse {p}" - This function takes an integer as an input and then performs a series of operations that essentially multiply the input by 2, subtract 2, and then check if the result is 0. If it's not zero, it goes back to the start and repeats the process. This is like entering multiple universes where the same actions keep happening.

  12. "you're invited to suffer {p}" - This function takes an integer as an input and compares it with the number 666 in a loop. If it's not 666, it increments the input and repeats the process. This creates a cycle of suffering until the input becomes 666.

  13. "hollup, let him cook {p}" - It initialises eax, ebx, and ecx to 0 and enters a "cook" loop where it increments eax, ebx, and ecx by one. It then moves the value of eax into edx and compares edx to {p}, if they are not equal it jumps back to "cook".

  14. "I'm feeling lucky {p}" - It triggers the interrupt associated with {p}.

Enjoy lol

kammt and others added 17 commits May 7, 2023 14:30
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Copy link
Copy Markdown
Contributor

@aengelke aengelke left a comment

Choose a reason for hiding this comment

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

Did you, like, you know, test these commands? 😅

.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).

.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..

.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.

.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.

.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...

.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.

.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.

@kammt kammt changed the base branch from main to develop June 11, 2023 13:23
.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)

@kammt
Copy link
Copy Markdown
Owner

kammt commented Jun 11, 2023

First of all, thank you for your contribution!
Could you change the PR title to something more fitting? "New features" is quite meaningless.

Regarding the proposed commands, here are my initial thoughts:

  1. So this is just an alias for rax is brilliant, but I like {p} to you know de wey? I don't really see why you'd need a special command for that 😅. Also, this is not a Meme.
  2. Same here
  3. Same here. Also, what does the meme have to do with the command's behavior?
  4. I like the command idea (=the meme), but not what it does. Maybe I can come up with a better behavior, I'll have a think about that one (Maybe it could call a function called order66 that the programmer can define?)
  5. I'd change it to Mr. Stark, I don't feel so good, but I like the idea
  6. This is also not a Meme
  7. See my review comment. I also wouldn't call that a Meme. ah shit, here we go again would be better imo (That command was in v0.1 with exactly that behavior). It would probably be a better implementation if the command jumped back to the start of the current function (That would require an update to the translation patterns in translator.c to support that though)
  8. Sure, why not
  9. I like to idea, but why would you require a register parameter for that? push rax, generate a random number, move it to .Ltmp64, pop rax, jump
  10. Well, I wouldn't call it stopping, it essentially generates a GP-Fault. You could also describe command number 8 as "stops program execution". Not sure about that one, since we already have you shall not pass! and there are already two commands that crash the program.
  11. That's not a Meme? Also, I don't really see the point behind that one 😅
  12. Hm, I don't know about that one. Also, writing it out as a sentence kind of destroys the reference to the meme (something like you're invited to: suffer would be more fitting imo). A bit like number 4: I like the idea (= the meme that was used), but not what the command actually does
  13. How did you come up with that behavior? This command could be used as an implementation for wait(2) when I come to implementing a fork-command (yes, that is planned). Your suggested behavior seems very random
  14. I don't think that the meme is fitting here. But it's true that access to int could be a good feature.

TL;DR: This is not something I'd merge right away. I'll leave it open and have a think about what makes sense and what doesn't. Right now, I would adapt (i.e. merge with a few modifications) 5, 8, 9 and maybe 10. @xarantolus what are your thoughts on this?

@kammt kammt added the enhancement New feature or request label Jun 11, 2023
@J-MR-T
Copy link
Copy Markdown

J-MR-T commented Jun 11, 2023

  1. I'd change it to Mr. Stark, I don't feel so good, but I like the idea

I also like that mnemonic, but I think setting all registers to 0 is almost a bit too useful for this project. What about sending a random signal to the parent process or maybe the process itself (that would of course only work on POSIX adjacent OSes, I'm not sure if execution on windows is supported?)?
Only if there isn't already a similar command ofc, I have a vague recollection of you telling me about something along those lines @kammt?

10/14.

I actually think that access to int via Stop, you vialoated the law! {p} would be quite fitting, as that comes as close to a meme interrupting something as I can think of.

@babyygemperor babyygemperor changed the title New features New memeasm commands Jun 12, 2023
@kammt
Copy link
Copy Markdown
Owner

kammt commented Jun 12, 2023

I also like that mnemonic, but I think setting all registers to 0 is almost a bit too useful for this. What about sending a random signal to the parent process or maybe the process itself

Well, it should revolve about the program becoming unstable. This would work with zeroing all registers, since it also zeroes the Stack Pointer (however, this is also achieved with Houston, we have a problem, so that's a little boring).
The problem I see with sending a random signal is that most of the time, this would just result in the program getting killed by the signal, with no "slow deterioration" involved. What could be done is that after that command has been read, the compiler will add instructions which alter the program's state (Stack Pointer, GP-Registers, or sending a signal). That would ofc be more work on the development side than just sending a random signal.

I'm not sure if execution on windows is supported?

Well, you can theoretically run it on Windows, but everything involving Signals until now (i.e. Martyrdom) is not supported

Only if there isn't already a similar command ofc, I have a vague recollection of you telling me about something along those lines @kammt?

I think you're talking about Martyrdom, where the MemeASM program sends SIGKILL to the parent process when it receives SIGINT

I actually think that access to int via Stop, you vialoated the law! {p} would be quite fitting, as that comes as close to a meme interrupting something as I can think of.

That's a good idea!

@J-MR-T
Copy link
Copy Markdown

J-MR-T commented Jun 13, 2023

Well, it should revolve about the program becoming unstable.

I see, that makes sense. Maybe I'm a bit obsessed with signals atm, because all my ideas seem to be based on them, but here I go anyways ^^: What about the system as a whole becoming unstable with the use of that command? Sending a random signal to a random (user) process might be an option. Could kill the x server, file manager deamon, or similar, or do almost nothing ^^.

But on second thought, that is a bit detached from the meme itself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants