Forum > Unix

problems with the AArch64 inline Assembler

(1/1)

derMischka81:
I use the inline Asssembler on my RPi3 with 64Bit OS.

I have problems with the following inline Assembler instruction


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---asm  add x1, x1, x7, lsl #3end; 
The Instruction should do the following thing:

x1 := x1 + (x7 shl 3)

but if I compile and check the results inklusive the assembly window I can see that the BarrelShift (lsl #3) is missing.


The Next Problem is a branch to a Object-function.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TTestObj1.testproc;beginend; TTestObj2.asmprob;nostackframe;assembler;asm  stp x0, x30, [sp, #-16]!   ldr x0, [x0, FTestObj1]  bl TTestObj1.testproc   ldp x0, x30 [sp], #16end; 
The Branch-Value/Address is not correct --> jumps to the branch line self (infinite loop)

Zvoni:
I was under the impression, that the ADD in Assembly has three operands: Destination, Source1, Source2
You have 4 operands

PascalDragon:

--- Quote from: derMischka81 on February 16, 2021, 01:28:19 pm ---I use the inline Asssembler on my RPi3 with 64Bit OS.

I have problems with the following inline Assembler instruction


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---asm  add x1, x1, x7, lsl #3end; 
The Instruction should do the following thing:

x1 := x1 + (x7 shl 3)

but if I compile and check the results inklusive the assembly window I can see that the BarrelShift (lsl #3) is missing.
--- End quote ---

You are aware that I as a compiler developer had already replied to this in on your thread in German forum? And that you should report this on the bug tracker?


--- Quote from: derMischka81 on February 16, 2021, 01:28:19 pm ---The Next Problem is a branch to a Object-function.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TTestObj1.testproc;beginend; TTestObj2.asmprob;nostackframe;assembler;asm  stp x0, x30, [sp, #-16]!   ldr x0, [x0, FTestObj1]  bl TTestObj1.testproc   ldp x0, x30 [sp], #16end; 
The Branch-Value/Address is not correct --> jumps to the branch line self (infinite loop)

--- End quote ---

I think you better use a combination of ADRP and ADR to load the address into a register and branch to that. What exactly the assembler reader generates for your code I'd need to check.


--- Quote from: Zvoni on February 16, 2021, 03:33:55 pm ---I was under the impression, that the ADD in Assembly has three operands: Destination, Source1, Source2
You have 4 operands

--- End quote ---

The ADD instruction (among others) can also have an additional shift left as fourth parameter. See for example here.

Jonas Maebe:

--- Quote from: derMischka81 on February 16, 2021, 01:28:19 pm ---I use the inline Asssembler on my RPi3 with 64Bit OS.

I have problems with the following inline Assembler instruction


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---asm  add x1, x1, x7, lsl #3end; 
--- End quote ---
This bug is fixed in trunk and fixes_3_2.


--- Quote ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TTestObj1.testproc;beginend; TTestObj2.asmprob;nostackframe;assembler;asm  stp x0, x30, [sp, #-16]!   ldr x0, [x0, FTestObj1]  bl TTestObj1.testproc   ldp x0, x30 [sp], #16end; 
--- End quote ---
While not yet supported, for now this at least gives a compilation error rather than resulting in invalid code. The compiler does not yet parse "ldr x0, [x0, FTestObj1]" correctly either though (it seems to ignore the "FTestObj1"; even if it does not exist, no compilation error is printed).

The RTL uses very little AArch64 inline assembly and since it's a new architecture, existing inline assembly tests are not checked for it (they would have to be translated first). So there are probably quite a few more bugs in its assembler reader...

Navigation

[0] Message Index

Go to full version