Help with assembler syntax for OUT

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
sjalloq
Active Member
Posts: 55
Joined: Tue Jan 12, 2010 1:49 pm

Help with assembler syntax for OUT

Postby sjalloq » Tue Feb 02, 2010 4:01 pm

OK, so I have no software background at all. Just wanted to throw that out there before I ask what may be a silly question. I don't think I can post the exact example so I've modified it to suit my questions.

Firstly, can someone explain access to the data region using the data pointer? Is it fixed and all access to data is an offset from this pointer?

Secondly, in the following assembler, can you explain in layman's terms what is going on? It is performing a read-modify-write but I'm unsure of the exact syntax meaning. Assume my_port is a 32-bit port that I want to access individual bits of. I pass one argument to the function which is stored automatically in r0.

Code: Select all

my_out_func:
ldw r11, dp[my_port]
out res[r11], r0
retsp 0


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

Postby richard » Tue Feb 02, 2010 9:03 pm

sjalloq wrote:Firstly, can someone explain access to the data region using the data pointer? Is it fixed and all access to data is an offset from this pointer?

The mapper gathers all writable data into a single region in the final image. The boot code initialises the dp register of every thread to the start of this region. If you use a label with a dp relative instruction then at link time the offset to that label from the start of the data region is patched into the instruction.

Secondly, in the following assembler, can you explain in layman's terms what is going on?

I've tried annotating the code:

Code: Select all

 // Define symbol my_out_func to be the current pc
my_out_func:
// Load the word at the address of the my_port symbol into r11.
// dp relative addressing is used (explained above).
ldw r11, dp[my_port]
// Output the value in r0 to resource whose resource identifier is held in r11
out res[r11], r0
// Jump to the value of lr (i.e. return from the function)
retsp 0


If the port is in its default mode (no serialisation or ready signals) then this instruction sequence will drive the value in r0 to the port's pins on the next falling edge of port's clock.
sjalloq
Active Member
Posts: 55
Joined: Tue Jan 12, 2010 1:49 pm

Postby sjalloq » Tue Feb 02, 2010 11:25 pm

Brilliant. Thanks for your help.

Return to “Development Tools and Programming”

Who is online

Users browsing this forum: No registered users and 5 guests