I'm trying to teach myself assembly. I've got years and year of experience with C, Java and Python- but I cant make ANY headway here and I'm about to give up.
So, I downloaded uVision4, and assumed I could just write a basic assembly program:
MOV R1, #0x7F0E0C2D
MOV R3, #0x1048B3C5
ADCS R1, R3, ROR #0x18
END
So, establish two variables, do an operation, done. Check the Registers for output and debugger for condition flags, surely.
Apparently, this is impossible.
I create the text file, write my code, save as a .asm file, then try to build-
It hates that.
Okay, so I create a new project, add the .asm file,
And it refuses, demanding I apparently write an entire device driver to do a god damn hello world.
How can I run a simple couple lines of code to start learning?
I do stuff like this all the time on my x86 desktop, using gdb to single-step code. Usually with x86 instructions, but it's doable for ARM cross-development, too. Build with
gcc -nostdlib foo.S
, and it should set the default entry point to the beginning of your .text section. You do get a warning from the linker, though:I had to modify your source for it to assemble. Here's my arm-simple.S:
Then you can use gdb and set a breakpoint at the first instruction, run it, and single step.
You can even do this in a cross-development environment, with a few wrinkles.
In one terminal, run QEMU on your binary, waiting for a debugger connection:
Use
-mcpu=something
for gcc, and-cpu model
for qemu if you want to be specific.In another terminal, run ARM gdb (in my case, from Ubuntu's gdb-arm-none-eabi package, since they Ubuntu doesn't distribute a arm-linux-gnueabi-gdb cross-ARM-gdb package for x86).
TODO: try gdb-multiarch. Regular gdb on an x86 desktop can only debug x86 binaries, so you definitely can't use that.
Then gdb shows:
It highlights the last register(s) modified, which is pretty great.
It seems to be too old to decode flags symbolically, though. modern x86 gdb does that.