L32R instruction with xtensa-esp32-elf-as assembler

qheinal
Posts: 25
Joined: Tue Feb 20, 2024 4:38 pm

L32R instruction with xtensa-esp32-elf-as assembler

Postby qheinal » Mon Apr 01, 2024 6:22 pm

Im using xtensa-esp32-elf-as compiler to compile asm code but if i use the L32R instruction it compiles to 0x410000. Which means the address i specified isnt actual included in the instruction. If i use L32I it works as expected. Am i missing something?

in the code im just doing this

Code: Select all

[code]L32R a4, 0x0fc0
[/code]

im using this to compile and build flat binary

xtensa-esp32-elf-as.exe -o code.o code.asm
xtensa-esp32-elf-objcopy.exe code.o -O binary code.bin

MicroController
Posts: 1701
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: L32R instruction with xtensa-esp32-elf-as assembler

Postby MicroController » Mon Apr 01, 2024 9:57 pm

I imagine it close to impossible to "manually" write L32R instructions. After all, the R means relative to the current program counter which quickly gets impossible to track. Accordingly, the ISA summary says the syntax is "L32R at, label". So declare a label for your constant data, use it with L32R, and let the assembler calculate the correct offset.

Thinking about it, I'm not even sure if the assembler will know the offset, because 'normally' the addresses of (global) symbols are defined by the linker during linking...

ESP_Sprite
Posts: 9726
Joined: Thu Nov 26, 2015 4:08 am

Re: L32R instruction with xtensa-esp32-elf-as assembler

Postby ESP_Sprite » Tue Apr 02, 2024 1:39 am

Decently sure MicroController hit the problem on the head. I imagine the assembler takes your 0x0fc0 argument as an absolute address (because that would correspond to putting a label there), but because the final resting place of a .o file is unknown, it can't calculate the offset between the PC and that address yet. As such, it puts a dummy value there and leaves it to the linker to fill in the real value as soon as it can be calculated.

Who is online

Users browsing this forum: Corand, ESP_Sprite and 85 guests