Is there any limit to how faster the code executes the lower level you get?
Just to clarify one point, assembly instructions have a one-to-one mapping into binary, and so there is no performance difference between programming in the two formats. We only use assembly because the opcode mnemonics, register names, and immediate values are easier for humans to write and understand than raw binary. Theoretically, our programs would be the fastest if they were all written in assembly. This is not the case in the real world because of how difficult it is to write good assembly code. So, we made higher-level programming languages where the more complex parts, like interacting with the hardware, were abstracted away. This way, we could make programming easier and more productive while keeping acceptable performance.
Once you get to the actual instructions executing on the CPU, it mainly comes down to hardware. As far as I know, the highest possible throughput is one instruction executed per clock cycle, ignoring fancy things like superscalar architecture and having multiple cores. Many of the improvements we've made to CPUs to improve this range from simple things like increasing clock speed, to more complex topics like pipelined architecture and branch prediction algorithms.
As a side note, the only fields I know of that still use some assembly code is in embedded systems (like Arduino), and cybersecurity. It's sometimes needed in embedded systems because you're typically working with microcontrollers that have very low clock speeds and not much memory, although this need has decreased significantly. For reference, the Arduino Uno has a 16MHz processor and 2KB of RAM. In cybersecurity, assembly is used in reverse engineering malicious binaries. By looking at a program's assembly code in a tool like Ghidra, you can get a better understanding of how it works on the inside and figure out exactly what it does.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now