This is truly brilliant how you take the time to break this down. I teach RE on C in ARM 64 and ARM 32 and I rarely see such good coverage of ARM well done!
@@LowLevelTV its brilliant thank for taking the time to do it. I would love t see a Raspberry Pi Pico raw Assembly tut if that interested you. We have the SDK from the RPI but its binding are focused more on C which is good but anyway im babbling...
Just found your channel through another video. I have already learned how to enter thumb mode for the purpose of more efficient programs on the Nintendo GBA. The UA-camr ChibiAkumas has several videos on ARM assembly as well. Just for a computer/game system angle. Subbed for more Pi Pico and Assembly videos. I like lower-level programming over those generic Python and other programming tutorial videos UA-cam wants to recommend me.
Same here, I learned about thumb mode from Chibiakumas' videos too. Something else I learned about GBA was that the bios calls are different depending on whether you're in ARM or THUMB mode. In ARM mode they're bit-shifted to the left 16 times. So in thumb mode you would do SWI 0x06 but in ARM you do SWI 0x06
I have two questions. What exactly does branch exchange do? And can you write thumb for aarch64 or is that not supported, are the only two modes aarch64 and aarch32?
From the ARMv8 manual "AArch64 state supports only a single instruction set, called A64. This is a fixed-length instruction set that uses 32-bit instruction encodings." :(
Good question! With ARM gcc, you can you the -mthumb flag to compile that piece of code to thumb mode. You will need to separate your C files into which ones you want to be thumb mode and which ones you want to be ARM. This is the answer at the compiler level, there may be C preprocessor flags that I'm not aware of that will have the same effect.
@@LowLevelTV I tried compiling for the RPi Pico with #pragma GCC target ("thumb") but the output files are a couple of bytes larger instead of smaller, and then I tried passing to Cmake CMAKE_C_FLAGS "-mthumb" but that spews errors about processor does not support such and such instruction in thumb mode.
Would it be cleaner to jump/unconditional branch to the thumb address (+1) during assemble time rather than compute it at runtime? And than same to switch back (masking out the lsb, if needed). That way you're not eating up all the saved bytes with mode swapping instructions. I'm kind of surprised the assembler doesn't emit a warning (or even an error) if you switch between modes and don't modify the instruction pointer in some way immediately before the transition.
Cool ! But question here, in Thumb mode any conditional instruction (except conditional branch instructions ) need to be in a IT block ( if then block ), am i right ? for example it eq moveq r0,r1
Searching for fault, fault detected, failure sits for device! ARM M type can only use thumb mode, ARM A type thumb and A32 using OS. But it is not possible, never ever executing a program in AMD64 written for ARM. Sorry, my fault!
@@lostulutz8526 It's possible to emulate. On linux you can install binfmt-support and qemu-user-static. This allows you to execute binaries for different architectures.
This is truly brilliant how you take the time to break this down. I teach RE on C in ARM 64 and ARM 32 and I rarely see such good coverage of ARM well done!
Glad you enjoyed it!
@@LowLevelTV its brilliant thank for taking the time to do it. I would love t see a Raspberry Pi Pico raw Assembly tut if that interested you. We have the SDK from the RPI but its binding are focused more on C which is good but anyway im babbling...
Just found your channel through another video. I have already learned how to enter thumb mode for the purpose of more efficient programs on the Nintendo GBA. The UA-camr ChibiAkumas has several videos on ARM assembly as well. Just for a computer/game system angle. Subbed for more Pi Pico and Assembly videos. I like lower-level programming over those generic Python and other programming tutorial videos UA-cam wants to recommend me.
Happy to hear it! Welcome to the channel
Same here, I learned about thumb mode from Chibiakumas' videos too. Something else I learned about GBA was that the bios calls are different depending on whether you're in ARM or THUMB mode. In ARM mode they're bit-shifted to the left 16 times. So in thumb mode you would do SWI 0x06 but in ARM you do SWI 0x06
i wish you were around when i was learning arm assembly in undergrad!
Excellent explanation! Thank your!
Wow I wish I would have found this channel earlier!
Thanks man!
4:59 that was so funny to me I literally fell out of my chair
I have two questions. What exactly does branch exchange do? And can you write thumb for aarch64 or is that not supported, are the only two modes aarch64 and aarch32?
From the ARMv8 manual "AArch64 state supports only a single instruction set, called A64. This is a fixed-length instruction set that uses 32-bit instruction encodings."
:(
Thank you very much!
What type of computer are you using? Where did you get that? And what OS is you running under?
Cool. Now, let's say you would want to do that from the comfort of C, how would one tell the compiler?
Asking for a friend.
Good question!
With ARM gcc, you can you the -mthumb flag to compile that piece of code to thumb mode. You will need to separate your C files into which ones you want to be thumb mode and which ones you want to be ARM.
This is the answer at the compiler level, there may be C preprocessor flags that I'm not aware of that will have the same effect.
@@LowLevelTV I tried compiling for the RPi Pico with #pragma GCC target ("thumb") but the output files are a couple of bytes larger instead of smaller, and then I tried passing to Cmake CMAKE_C_FLAGS "-mthumb" but that spews errors about processor does not support such and such instruction in thumb mode.
@@eFeXuy the pico is an M0+ than only support thumb mode.
Awesome!!
how did you run the programs without qemu-arm.
Thumbs UP. BIGLY!
Would it be cleaner to jump/unconditional branch to the thumb address (+1) during assemble time rather than compute it at runtime? And than same to switch back (masking out the lsb, if needed). That way you're not eating up all the saved bytes with mode swapping instructions.
I'm kind of surprised the assembler doesn't emit a warning (or even an error) if you switch between modes and don't modify the instruction pointer in some way immediately before the transition.
Can you make a arm32/aarch32 tutorial?
1:58 Once the CPU performs the jump, is PC odd or even? Does it actually start executing at an odd address?
No, its starts executing at an even address, but in Thumb mode.
Cool !
But question here, in Thumb mode any conditional instruction (except conditional branch instructions ) need to be in a IT block ( if then block ), am i right ?
for example
it eq
moveq r0,r1
That's like the Great Architect from Happy Three Friends.
When I run my binary I got an error : -bash: ./001.elf: cannot execute binary file: Exec format error
Why is it called THUMB?
When I run my binary I got an error : -bash: ./001.elf: cannot execute binary file: Exec format error
Searching for fault, fault detected, failure sits for device! ARM M type can only use thumb mode, ARM A type thumb and A32 using
OS. But it is not possible, never ever executing a program in AMD64 written for ARM. Sorry, my fault!
@@lostulutz8526 It's possible to emulate. On linux you can install binfmt-support and qemu-user-static. This allows you to execute binaries for different architectures.