User Tools

Site Tools


flag_operations_are_free

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
flag_operations_are_free [2026/01/15 05:29] appledogflag_operations_are_free [2026/01/15 05:32] (current) appledog
Line 197: Line 197:
  
     let addr = (instruction >> 8) & 0x00FFFFFF;      // Extract upper 3 bytes     let addr = (instruction >> 8) & 0x00FFFFFF;      // Extract upper 3 bytes
-     + 
-    You're adding a bit shift, a bitwise AND, plus you're creating an intermediary variable access. In the end this is almost 10% slower than just calling fetch_byte().+You're adding a bit shift, a bitwise AND, plus you're creating an intermediary variable access. In the end this is almost 10% slower than just calling fetch_byte().
          
 == Conclusion == Conclusion
Line 229: Line 229:
  
 If you want to get faster than this, you need to rewrite the entire switch in C or maybe Rust. If you want to get faster than this, you need to rewrite the entire switch in C or maybe Rust.
 +
 +As a result of all this, I now know that flag operations are free inside an opcode and I don't need to have a "fast flags" bit. Simply checking that bit every instruction was slowing down the system by far more than it saved.
 +
 +//Moral: "Premature optimization is the root of all evil."//
flag_operations_are_free.1768454993.txt.gz · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki