MemeAssembly icon indicating copy to clipboard operation
MemeAssembly copied to clipboard

New memeasm commands

Open babyygemperor opened this issue 2 years ago • 4 comments

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

babyygemperor avatar Jun 11 '23 09:06 babyygemperor

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 avatar Jun 11 '23 14:06 kammt

  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.

J-MR-T avatar Jun 11 '23 16:06 J-MR-T

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!

kammt avatar Jun 12 '23 10:06 kammt

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.

J-MR-T avatar Jun 13 '23 05:06 J-MR-T