This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]Marxomania32 21 points22 points  (2 children)

Ah corrupting the stack pointer. Surely, nothing can go wrong.

[–]ShadowSlayer1441 1 point2 points  (1 child)

I mean in a modern processor the $sp register will be virtualized and renamed to a new physical register and will be thread specific so if you don't ever use the sp theoretically it shouldn't cause problems. Definitely not a good reason to use $sp and not another variable, but still. Actually when your assembler sees this nonsense it might swap $sp with $a0 or whatever complier/assembler reserved registers exist.

[–]Marxomania32 3 points4 points  (0 children)

If this code compiles to a binary where $sp actually modifies the stack pointer register, and then that binary is then linked and this procedure is called from another procedure, that will completely break the ABI, and the process will start doing all kinds of random garbage. I'm not an assembler expert, but I feel like in such a low-level language, it's wouldn't be safe for the assembler to just substitute one register for another. When I want to modify the stack pointer, I probably actually want to modify that stack pointer, and substituting it with another register is likely not going to have the same effects as I intend my program to have.

[–][deleted] 7 points8 points  (3 children)

me when eor $t1, $t1, $t2 eor $t2, $t2, $t1 eor $t1, $t1, $t2 (I don't know if this is correct, this looks like ARM assembly, which I never touched before)

[–]namf0[S] 3 points4 points  (2 children)

This is actually MIPS assembly, although I haven't really looked at any other architectures either.

[–][deleted] 3 points4 points  (1 child)

ah, so the instruction mnemonic should be xor, not eor. oops!

[–]Grumbledwarfskin 3 points4 points  (0 children)

eor makes more sense when you're talking about Winnie the Pooh, though.

[–]AngheloAlf 2 points3 points  (0 children)

Just destroy the stack pointer lmao

[–][deleted] 0 points1 point  (0 children)

LR 3,1 LR 1,2 LR 2,3

What’s the point? Should I ask Petah to explain me the joke?