I was wondering if it were possible to modify the linux assembler in order to change the function of "-" to "+" and vice versa.
I was also wondering if this would affect the whole system making it collapse. I apologize if this question is not appropriate here. Please explain why if it is the case.

2+2 = 0
2-2 = 4

My objective is to see what applications this could have for a potential computer virus (I hope this is allowed here).

  • $\begingroup$ What do you mean by "change the function of - and +"? $\endgroup$ – Yuval Filmus Jun 4 '20 at 11:19
  • $\begingroup$ The answer is anyway negative. You can change as all you like. This won't make any difference for existing executables. $\endgroup$ – Yuval Filmus Jun 4 '20 at 11:19
  • $\begingroup$ I mean changing what they do: 2-2 = 4 2+2=0 ... I edited the question so it makes sense. $\endgroup$ – david david Jun 4 '20 at 11:22
  • $\begingroup$ assemblers are just language translators to convert assembly code into machine code. You could modify the source of assembler to swap the role of add and sub mnemonics. $\endgroup$ – rsonx Jun 4 '20 at 13:29
  • $\begingroup$ Would it affect the whole system? $\endgroup$ – david david Jun 4 '20 at 14:01

While this is trivially possible, the fundamental flaw in your idea is that assemblers are not interpreters. Python programs are run by the Python interpreter, Swapping - and + in the Python interpreter would likely crash all Python programs. But normal programs are executed directly by the CPU. The assembler is not involved in their execution.

  • $\begingroup$ In that case, would there be any other alternative for doing what I mentioned before? I guess that if I changed the python interpreter, I could still crash the OS as there are a lot of python programs ... $\endgroup$ – david david Jun 5 '20 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.