Why are integers processed faster than bytes in NDS?

I noticed that my nds application is a little faster when I replace all byte instances with integers. all examples on the Internet put u8 / u16 instances when possible. is there a specific reason why this is so?

+6
source share
2 answers

The main processor used by the Nintendo DS is ARM9, a 32-bit processor.

Link : http://en.wikipedia.org/wiki/ARM9

RpFsO.gif

Typically, the CPU will perform word-size operations, in this case 32-bit. Depending on your operations, converting bytes to integers or vice versa can cause additional processor overhead. This conversion and the potential lack of instructions for values ​​other than 32-bit integers may result in a lack of speed.

+16
source

In addition to what Daniel Lee said, memory access on ARM platforms should be aligned according to the words, i.e. memory samples should be a multiple of 32 bits. Removing a byte variable from memory involves obtaining the entire word containing the corresponding byte, and performing the necessary bitwise operations to match it in the least significant bits of the processor register.

These additional instructions are automatically generated by the compiler because it knows the actual alignment of your variables.

+7
source

Source: https://habr.com/ru/post/920069/


All Articles