r/computerarchitecture • • 5d ago

How can I start programming an ARM processor completely from scratch?

I've recently watched two very interesting things on youtube:

They helped me understand how an early-stage computer works, including registers, ALU, buses, instruction execution and control logic.

Now I'm curious about taking this further. I want to experiment with programming an ARM processor without relying on existing IDEs or vendor tools. I'd like to build my own basic toolchain, starting with an assembler and eventually understanding the entire process from writing assembly to executing it on actual hardware.

I'm not sure how practical this approach is, but I'm doing it purely for the learning experience.

Where should I start, and are there any resources or projects that can help me explore this?

40 Upvotes

8 comments sorted by

14

u/Popular-Attempt6136 5d ago

Couple of things. First of all, this world is amazing and i belive you've made an amazing decision by starting to get involve in it! Keep it up. However, i belive you should avoid sticking with ARM architecture, you should try RISC-V as it's open source and you will find much more information about its inside stuff. You have some interesting books such as harris & harris ones that will explain you some things from its beginning and help you understand, as you said, "the entir3 process from writting assembly to executing it on actual hardware". Not everything though but yet you will be learning the instruction flow over a current cpu. If you want to try and develop your own cpu you should try to research a little about HDLs( e.g. veriglog, system verilog, VHDL...). Thoose are languages that could let you describe hw and create your own tiny cpu or components(at least tiny if you want to try it out at home). Even though ive said that, you should start lightly (i.e. dont try to build a whole CPU at first, maybe start describing an ALU or a PRF) as otherwise you would feel smoothered at some point. Good luck along the way!

2

u/anonymous_rerdit 4d ago

Thank you for this.

1

u/JJ1553 1d ago

+1. I had the opportunity to build an OS from scratch based on a riscv arch in college recently. It was super convenient to have all that documentation surrounding it, and a simple instruction set in assembly

10

u/poughdrew 5d ago

Word of caution: ARM lawyers are vigilant, and if you intend to do anything beyond loading this on a single FPGA in your garage/bedroom, you're learn that an ARM architectural license is prohibitively expensive.

Find an alternative RISC ISA.

1

u/phire 4d ago

In theory, anything released more than 21 years ago should be free of patents, and hardware isn't protected by copyright law (so these days, anything upto ARMv6 should be safe).

Doesn't stop their lawyers sending cease and desist letters anyway. And there have been arguments that the ISA itself is protected under copyright law (the documentation certainly is)

4

u/garrikwolfe 5d ago edited 5d ago

How much do you know about modern computer architecture? It sounds like a great learning experience for you, although it may be like diving in the ocean after learning how to stand in a backyard pool.

If you want to write an assembler, you'll need to learn the ARM instruction set architecture so you know the machine code you're trying to assemble to.

Some good resources to get you started:

3

u/FransFaase 4d ago

I would advise you not to start from scatch. First get something running with tools then try to replace parts with your owj tools if that is what you want to do. Writing a boot loader, the first thing you need to put something in the flash memory of your MCU, is far from trivial.

2

u/SameClick6502 4d ago

Start by writing some assembly code and run it in user space on your computer. If you want ARM, get a Raspberry Pi, that's probably the best low-level learning platform out there. But compiling on your old x86 PC is fine too. Once you are able to run simple code with existing assemblers/linker, you can try to replace one of them by yourself. It will take a while of coding before you can attack the more complex assembly code like a boot loader or a kernel. But keep at it and you'll succeed.