So I am programming in assemply, this is just a simple code so I can learn how to allocate arrays in order to use them on NEON programming later.
ASM_FUNC(FPE)
.data
.balign 8
array: .skip 80
array1: .word 10,20,30,40
.text
ldr x0,=array
mov x1,#10
check:
cmp x1,#1
bne loop
b exit
loop:
str x1,[x0],#8 //Stores the value in x1 into x0 and moves the address +8 bytes
sub x1,x1,#1 //x1--
b check
exit:
mov x0,#11
ret
So, some parts are commented so I could try to find where the code is breaking (I don't have debug on my system).
I started commenting the calculation part and added a mov x0,#11 in the end right before the ret to see if the problem was on the calculation. Turns out it was not.
When I uncommented the array: .skip 80 and ldr x0,=array my application would just stick there if no response.
Can anyone please tell me what I am doing wrong? I am using A64 on armv8 assembly
The entry point is called from this c program:
void PocAsm_EntryPoint ( )
{
Print(L"========== ASM ==========\n");
UINT32 fff = FPE();
Print(L" %d \n",fff);
Print(L"=========== ASM ===========\n");
Print(L"Test version 0.24 \n");
return 0;
}
Unfortunately I didn't find the definition of the Print, so I apologize
This is an attempt to answer to the following question: does the
FPE()function work as expected, while removing everything else from the equation, using standard tools such asqemu-system-aarch64andGDB.The code for the
FPE()function will be compiled for a Cortex-A53 qemu-virt machine.Prerequisites:
Ubuntu 20.04:
sudo apt-get install qemu-system-armWindows 10: download and install the
qemu-w64-setup-20201120.exeinstaller from here.aarch64-none-elftoolchain forCortex-Ais installed. It can be downloaded from the ARM WEB site. There are versions for both Linux and Windows 10.FPE.s:startup.s:Building:
We will build
FPE.elffor the qemu-virt machine (RAM starts at0x40000000):Debugging:
Start qemu in a shell:
Start
GDB:GDBshould start:From this point, the commands
stepi,p/x $x0, andx/10g 0x40010050could be used for monitoring the program behavior until it will reach theexitlabel.We will just here display the 10 elements in the array at the start and exit breakpoints:
Single-stepping from this point shows that the program returns properly from its execution:
The answer to the question would therefore be: Yes, the code for the
FPE()function is working properly.The exact same procedure can be run on Windows 10, this is just a matter of adjusting the three commands that were used for running
aarch64-none-elf-gcc,qemu-system-aarch64andGDB.Comparing a dump of your object file with the one I tested may help understanding the issue:
Dumping the complete ELF file of the minimal example would give: