| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| en:multiasm:papc:chapter_6_14 [2025/11/16 17:03] – ktokarz | en:multiasm:papc:chapter_6_14 [2025/11/18 11:08] (current) – ktokarz |
|---|
| Code optimisation is implemented well in modern compilers. The machine code is generated using techniques that reduce the number of unwanted instructions, like loop unrolling. Compilers enable data parallelism with the extensive use of vector calculations. However, because they must be universal, the output code is always generic in some elements, and a good assembler programmer can identify places for improvement. | Code optimisation is implemented well in modern compilers. The machine code is generated using techniques that reduce the number of unwanted instructions, like loop unrolling. Compilers enable data parallelism with the extensive use of vector calculations. However, because they must be universal, the output code is always generic in some elements, and a good assembler programmer can identify places for improvement. |
| |
| The most important thing to consider when writing a program in any programming language is to cooperate with the processor and not work against it. This includes the proper placement of data in memory, taking into account both alignment and cacheability, avoiding conditional jumps, manually unrolling loops, and utilising the maximum possible register sizes available in the machine. These are just a few examples. As a rule, assembly language programming, because the programmers know what they want to achieve, usually allows for better code optimisation than compiler-generated code. Of course, this comes at the cost of more time spent writing the program and an increased potential for errors. However, it's essential to remember that a program written in assembly language does exactly what the programmer intended and isn't dependent on fragments of code, which can be unknown when using external libraries. | In certain computer systems, it is possible to reduce energy consumption by modifying the approach to software implementation from continuous execution to interrupt-driven execution. In continuous execution, the software continually executes the infinite loop and reads data from the input elements at regular intervals. In an interrupt-driven approach, the processor enters the idle state when there is nothing to be done. Input devices signal when new data appears, indicating a need to wake the processor up to execute the necessary part of the code. In the Windows operating system, power management is implemented as part of system functionality, and user software can't control devices and their mode of operation. Devices are controlled using drivers provided by their vendors. Interrupt handlers are elements of these drivers. |
| | |
| | The most important thing to consider when writing a program in any programming language is to cooperate with the processor and not work against it. This includes the proper placement of data in memory, taking into account both alignment and cacheability, avoiding conditional jumps, manually unrolling loops, and utilising the maximum possible register sizes available in the machine. These are just a few examples. As a rule, assembly language programming, because the user knows what they want to achieve, usually allows for better code optimisation than compiler-generated code. Of course, this comes at the cost of more time spent writing the program and the increased potential for errors. It also requires extensive knowledge and experience from the programmer. However, it's essential to remember that a program written in assembly language does exactly what the programmer intended and is not dependent on fragments of code, sometimes completely unknown, when using external libraries. |
| |
| The course on energy efficient programming ((https://open.hpi.de/courses/cleanIT-x862022)). | |