ESP32 instruction set or assembly (ASM) programming docs?

jens.alfke
Posts: 14
Joined: Wed May 02, 2018 4:26 pm

ESP32 instruction set or assembly (ASM) programming docs?

Postby jens.alfke » Tue Sep 29, 2020 5:16 pm

I'm looking for documentation of the ESP32 instruction set, for assembly language programming. I've found some old (2010) Xtensa ISA docs, but their designs are so configurable that it's not much use for a specific CPU.

I've seen two threads from a few years ago asking about this, and replies from Espressif saying that the ISA docs are somehow under NDA from Xtensa and they were trying to get permission to post them. But this never got resolved, apparently.

🤯 Is it just me, or is it crazy for there to be a CPU you can buy but whose instruction set you aren't allowed to know? I've been exposed to assembly language since I was a teenager exploring my Apple II, when I was crazy enough to hand-assemble 6502 instructions and type in the hex opcodes. I haven't written much assembly since then, but I've certainly had to know it well enough to read it when debugging C/C++ code for 68000, PowerPC, x86 and ARM.

(At the moment, I'm interested because I'm considering implementing a FORTH interpreter for ESP32. This requires a small but intricate core of assembly code to bootstrap it, before the rest of it can be implemented in FORTH.)

I don't suppose anyone's looked into the source code of GCC's code-generator module for ESP32? Given enough work, the instruction set could be figured out by reading that carefully... 🧐

--Jens

mikronauts
Posts: 23
Joined: Wed Dec 09, 2015 8:11 pm

Re: ESP32 instruction set or assembly (ASM) programming docs?

Postby mikronauts » Tue Sep 29, 2020 7:02 pm

Yes, this is very frustrating. I have a similar issue if I want to try to port the VM for my basic compiler.

You could write it in C, once it works save assembly code, edit, assmble it, make sure it still works.

Using old docs, improve and replace, keep re-testing.

This sucks, but until proper docs show up...

btw, gcc generated code would not use all possible best instruction so there would be a big performance hit anyway.

jens.alfke
Posts: 14
Joined: Wed May 02, 2018 4:26 pm

Re: ESP32 instruction set or assembly (ASM) programming docs?

Postby jens.alfke » Wed Sep 30, 2020 10:44 pm

You could write it in C, once it works save assembly code, edit, assmble it, make sure it still works
I haven't looked — is there actually an assembler/disassembler in the toolchain?

Of course, trying to learn a completely new instruction set by reading disassembly is not my idea of fun, or even my idea of a productive use of time. Though I can imagine someone like teenage-me attacking the problem just for the challenge...

PS: Modern optimizing C compilers can generate code that's often more efficient than hand assembly, at least for x86 and ARM. But the ESP32 back-end may not be well enough tuned to reach those levels.

Who is online

Users browsing this forum: No registered users and 1 guest