assembly only project

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

assembly only project

Post by MFlamer »

I'm having trouble getting a simple project of 1 file of assembly to build. This the code and error.



.globl _start
_start:
ldc r1, 100
notmain:
sub r1,r1,1
bt r1, notmain

ldc r3,0x4000
shl r3,r3,4
setc res[r3],0x8
ldc r1,0x6
setc res[r1],0x8
// ldc r2, 8
// setd res[r1], r2
setc res[r1],0xf

top:
ldc r0, 0x8
out res[r3], r0
ldc r0, 0x4
out res[r3], r0
ldc r0, 0x2
out res[r3], r0
ldc r0, 0x1
out res[r3], r0
ldc r0, 0x2
out res[r3], r0
ldc r0, 0x4
out res[r3], r0
bu top



**** Build of configuration Debug for project test ****

xmake CONFIG=Debug all
No modules used.
Checking xmos.com for board support package: XC-1
Installed BSP for target XC-1
Creating dependencies for test.S
Creating test_Debug.xe
../src/test.S: Error: Multiple definition of '_start'
crt1.S: Error: first defined here
xmake[1]: *** [bin/Debug/test_Debug.xe] Error 1
xmake: *** [bin/Debug/test_Debug.xe] Error 2

What am I missing? Thanks.

I just found the xcc comand line manual, I think this will help get me going....
Last edited by MFlamer on Fri Jan 23, 2015 3:41 pm, edited 1 time in total.


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Please post the error and details on how you are compiling this source file.
MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

Post by MFlamer »

I added the error output to the original post. Thanks.
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Try the following:

1) Create a new project -> change the target hardware to XC-1A

2) cut & paste the text below into the default .xc file. Then save as same file name but with .s suffix.

3) Then manually delete the empty .xc file leaving only the .s assembler source file.

4) Build the project.

**** Build of configuration Debug for project first_assembler ****

xmake CONFIG=Debug all
No modules used.
Build Complete


Credit goes to this thread:
http://www.xcore.com/forum/viewtopic.ph ... =assembler

Code: Select all


   .text
   .file "first_assembler.S"

   .globl main

   .globl main.nstackwords
   .linkset main.nstackwords, 0

main:
_start:
 entsp   0
 ldc r1, 100
notmain:
 sub r1,r1,1
 bt r1, notmain

 ldc r3,0x4000
 shl r3,r3,4
 setc res[r3],0x8
 ldc r1,0x6
 setc res[r1],0x8
 setc res[r1],0xf

top:
 ldc r0, 0x8
 out res[r3], r0
 ldc r0, 0x4
 out res[r3], r0
 ldc r0, 0x2
 out res[r3], r0
 ldc r0, 0x1
 out res[r3], r0
 ldc r0, 0x2
 out res[r3], r0
 ldc r0, 0x4
 out res[r3], r0
 bu top
MFlamer
Member++
Posts: 19
Joined: Wed Jan 14, 2015 2:17 am

Post by MFlamer »

Built first try. Thanks. I'll readup on the changes to the file and see what I was missing. Probably the "main:" label.