arm - Assembly Language: How to stick a list of array into a word? -
how combine array of 4 byte 1 32-bit. first item should go significant nibble of result. store result in 32-bit variable result. input: [list] = 0xc, 0x2, 0x6, 0x9 (each item byte, use dcb define variable of type byte) output: [result] = 0x0c020609 edit answer: add r1, r0 mov r1, r1, lsl #8 add r0, r0, #8 add r1, r0 mov r1, r1, lsl #8 add r0, r0, #8 add r1, r0 mov r1, r1, lsl #8 add r0, r0, #8 add r1, r0 what you're describing same thing treating 4 contiguous bytes 32-bit integer stored in big-endian byte-order. according gcc (on godbolt compiler explorer ), best way byte-swap big-endian arm-native endian instruction arm provides explicitly purpose: rev r0, r0 #include <stdint.h> #include <endian.h> #include <string.h> // type-punning unions alternative memcpy char array int union be_bytes { uint32_t be_word; char bytes[4]; }; uint32_t be_bytes_to_native( char *array ) { union be_bytes tmp; memcpy(tmp.bytes, array, 4); ...