ASM and a LDIVU example
Posted: Fri May 07, 2010 12:23 pm
If you read the ASM manual ver. 9.9 you will probably get confused - until it's updated.
Reading the The XMOS XS1 Architecture describes the LDIVU operation as
The XS1 Assembly Language Manual seems to show two incorrect ways of writing it
For the moments it's seems to be several errors explaining the operands in the ASM manual.
The correct notation is found in the XS1 architecture.
Gives the following result on the console:
Q=6, R=1
31/5 = 6 + 1/5
Q is the Quotent, R is the reminder and the operation is (uint_64) X/(uint_32) y where X is expressed as 2 32-bits number Xhigh and Xlow.
Thus its:
LDIVU Quotent,Reminder,Xhigh,Xlow,Y
Reading the The XMOS XS1 Architecture describes the LDIVU operation as
Code: Select all
LDIVU d, e, x, y, v
Code: Select all
LDIVU d,x,y,e,v ldivu d, e, v, x, y
The correct notation is found in the XS1 architecture.
Code: Select all
#include <stdio.h>
int main(){
unsigned int Xh=0,Xl=31;
unsigned int y=5;
unsigned int Q;
unsigned int R;
asm("LDIVU %0,%1,%2,%3,%4" : "=r"(Q) , "=r"(R) : "r"(Xh) , "r"(Xl) ,"r"(y));
printf("Q=%u, R=%u",Q,R);
}
Q=6, R=1
31/5 = 6 + 1/5
Q is the Quotent, R is the reminder and the operation is (uint_64) X/(uint_32) y where X is expressed as 2 32-bits number Xhigh and Xlow.
Thus its:
LDIVU Quotent,Reminder,Xhigh,Xlow,Y