assembler syntax

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

assembler syntax

Post by MFlamer »

Why are there 2 types of syntax? I see reference to an "Architectural" syntax in the Assembly Programming Manual but it's not clear what the difference is between them. If I try.....

Image

Code: Select all

 ldw 	r1, cp[r10]
I get the following error,
../src/test.S:29: Error: A00049 no format matching for instruction: 'ldw'
if I try:

Code: Select all

LDW 	r1, cp, r10 
I get the following error,
../src/test.S:31: Error: A00000 Use of "LDW" outside of architectural syntax mode.
What's up?


MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

Post by MFlamer »

OK, I see the XC-1 Architecture manual does list the registers allowed for use with each instruction...and cp is now valid in ldw.
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm
Contact:

Post by Bianco »

The architectural assembler maps 1 to 1 to the instruction set.
The other assembler is a bit less verbose and easier to use, it has assembler instructions that can map to different processor instructions, for example: a processor might have two jump instructions: one to jump forward and one to jump backward. With the easier assembler you only require 1 instruction and it will map to the right processor instruction depending on the label you jump to.

There are assembler directives to switch between the two assembler types.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am
Contact:

Post by segher »

And your actual problem is there is no "ldw r1,cp[r10]"
instruction; you need to write something like

Code: Select all

ldaw r11,cp[0]
ldw r1,r11[r10]
HTH,

Segher
MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

Post by MFlamer »

Got it.

Is there a way to set a register alias? something like

Code: Select all

.set A, r0
Thanks.
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

MFlamer wrote:Is there a way to set a register alias?
There's no mechanism built into the assembler itself. However assembly files with an uppercase .S extension are run through the C preprocessor, so you could use a preprocessor macro instead:

Code: Select all

#define A r0
MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

Post by MFlamer »

I forgot about that! Cool, I can do this and more with the preprocessor. Thanks.
MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

Post by MFlamer »

How are the following instructions any more useful then a simple add or sub? I must be missing something...
Image
Post Reply