Both are available simultaneously if the CPU supports both. Most CPUs support both, some support only one. (1) Arm vs Thumb : these are two different instruction sets. There are a couple of concepts to disentangle here: Ldr r6, load the current outer loop index value into r6 Ldr r5, load the minimum index value into r5 Mov r3, r4 set the minimum index to the current index Ldr r6, load the inner loop's next value to r6īge in_loop_inc if r6 is greater than or equal to r5, increment and restart loop Ldr r5, load the minimum index's value to r5 Mov r4, r1 set the inner loop index to the outer loop index Mov r3, r1 set the index of the minimum value to the current array index Str r2, store r2's value to the base address of the array plus the offset stored in r1Īdds r1, #4 add 4 to the offset (1 word in bytes)Ĭmp r1, #40 check if we've reached the end of the array Ldr r0, arr_adr load the address of the start of the array into register 0 Does the qemu-arm executable only run full ARM binaries? If so, is there another qemu package I can install to run a thumb binary? I am running on Ubuntu Linux 20.04 LTS, using qemu-arm version 4.2.1 (installed from the package manager). I suspect that qemu is trying to run my code as if it were compiled for the full ARM instruction set instead of thumb, but I'm not sure why this is. This is causing my program to not work correctly. However, when I change the directive in my code, it compiles fine but behaves strangely in that the program counter increments by 4 after every instruction instead of the 2 that I expect for thumb. Ultimately I would like to be able to write some assembly for my Raspberry Pi Pico, which has an ARM Cortex M0+, which I believe uses the armv6-m option. This worked fine and the program initialized the array and sorted it as expected. I initially assembled it using the armv8-a option and ran the program under qemu while debugging with gdb. I'm trying to learn the basics of ARM assembly and wrote a fairly simple program to sort an array.
0 Comments
Leave a Reply. |