How do arithmetic instructions work in the code? #34
-
Hello! I'm trying to understand how arithmetic instructions work in the code. It's pretty confusing and vague, both add and subtract seem to mess with bits randomly. It'd be nice if you could explain it to me as I'd rather not figure this all out myself if I don't have to. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello! I agree, the backend is quite abstract, arguably a little more than it needs to be, and I'm working to simplify it. That said, addition will work the same way regardless; we implement addition the same way real hardware does, with a series of full adders, or more specifically, the truth table associated with a full adder. The code here is just implementing this truth table while inheriting all the mechanical overhead needed to generate the code. |
Beta Was this translation helpful? Give feedback.
Hello!
I agree, the backend is quite abstract, arguably a little more than it needs to be, and I'm working to simplify it. That said, addition will work the same way regardless; we implement addition the same way real hardware does, with a series of full adders, or more specifically, the truth table associated with a full adder. The code here is just implementing this truth table while inheriting all the mechanical overhead needed to generate the code.