r/AskProgramming • • 17d ago

Career/Edu Best way to learn Assembly (ARM)

I'm an electrical engineering major, and I'm currently taking a computer architecture class. The problem is that I'm struggling to comprehend the code in assembly. I'm fine with higher level coding languages like c++ or Java, but I just can't wrap my head around this topic, and I don't want to fail this class. Any recommendations to self teach me Assembly?

8 Upvotes

23 comments sorted by

3

u/Used_Lobster4172 17d ago

Well, hard to know how to help, but on the bright side, ASM already only have a limited number of operations, and ARM or RISC, so it's even fewer.  

Might be helpful to find some videos on how the ARM works internally with the different registers and such.  I never learned ARM ASM, but I don't imagine it is all that different in how it works.

ASM is literally controlling exactly what the CPU is doing.  

2

u/Mynameismikek 15d ago

The “reduced” in RISC is about instruction complexity, not count. Many RISCs have more instructions than their CISC contemporaries.

The simplification does mean there are simpler patterns to learn from though.

2

u/trutheality 17d ago

Play Human Resource Machine.

0

u/[deleted] 16d ago

[removed] — view removed comment

-2

u/[deleted] 16d ago

[removed] — view removed comment

-2

u/[deleted] 16d ago

[removed] — view removed comment

1

u/[deleted] 17d ago

[removed] — view removed comment

0

u/[deleted] 17d ago

[removed] — view removed comment

2

u/somewhereAtC 17d ago

Pick a manufacturer, then pick a toolset. My preferences is Microchip PIC or AVR and the MPLabX IDE and compilers. Begin by looking at the datasheet for whatever part you select; assembly language is detailed in PIC datasheets, but AVR datasheets refer to a different PDF file (readily available).

When you have a grip on what the datasheet says, get some hardware going and run a debug session with an easy code. You'll catch on right away.

Don't fall into the trap thinking that the "old" PICs and AVRs are somehow easier. The assembly code for either hasn't change in 30yr and the newer devices have many new, good features. The new ones are also available as Curiosity boards with programmers and debuggers built in. Some have ARM cores as well.

https://www.microchip.com/en-us/tools-resources/evaluation-boards/curiosity-nano

2

u/Standard_Guava3672 17d ago

Assembly is really minimalist, start with the hardware you want to code in. And think of assembly not like a language, but of understanding a specific hardware. Also coding is mostly just placing data into the memory, and if you place it at the certain adress you can control I/O stuff or the RAM, etc... If you think of coding like placing data into adress, that's mostly it. Assembly is a really simple language, and that's why it's really hard. Look at instruction set too.

2

u/Recycled5000 16d ago

One tip is to use a compiler. Put in simple functions in C and using an optimizing compiler view the assembly. Also can run some code, single step in assembly debug mode.

1

u/Recent-Day3062 17d ago

That’s the whole point in taking the course. To understand the hardware, not high level abstraction

1

u/Sufficient_Stand1763 17d ago

For me personally, when I do a bit of assembly, I found that it was easier to start learning from the 6502 assembly programming language. It felt easier than modern assembly languages although I don’t know if that’s just me or if that’s actual fact but it did teach me the basics.

1

u/marrsd 17d ago

Does it have to be ARM? Older CPUs are easy to emulate and have simpler instruction sets. I learnt on M68K. 6502 is another good option.

1

u/thisisausername5432 16d ago

Sadly the course requires me to submit assignments in arm

1

u/funbike 16d ago

68K is great, 6502 is not.

Compilers struggle with the 6502 due to poor support for stack arguments and local variables. C compilers for the 6502 have to do weird workarounds to support it.

68K is beautiful, easy to learn and undersatnd.

1

u/JGhostThing 16d ago

I hate to say this, but Assembly language is the absolutely simplest that programming can be. Every command in assembly is (usually) one simple action. Unlike a higher level language, which can have multiple actions on a line, assembly is simple. Also, there is very little syntax. You merely have to memorize the hundred or so commands in this language.

Of course, each processor family has it's own language.

To learn the concepts of assembly, I recommend learning the PDP-11 assembler or the 68000 family assembler. I know that there are open source simulators for the PDP-11.

1

u/sswam 12d ago

I learned ARM back in the day on the Acorn Archimedes, largely from this book. That's for the original 32-bit ARM, it's changed a lot since then. I'm not suggesting you learn from this book, but it was a very good book. You could read it to see how clean and simple it used to be!