UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 18568

6.1i EDK_GNU: MB-GCC generates read instruction when XIo_Out32 macro is bracketed

Description

Keywords: mb-gcc, EDK, read, instruction, Xlo_Out32

Urgency: Standard

General Description:
The "*(ptr) = value" construct (as used in the XIo_Out32 macro) is compiled with an extra read from *(ptr) location when enclosed in multiple parenthesis/curly brackets. This creates hard-to-find bugs when the assignment is to a register from which reading produces a side-effect (like FIFO peripheral).

To reproduce, look at the assembly listing from the following two code snippets:

/* Correct */
main()
{
XIo_Out32(0x12, 0x34);
return 0;
}

addik r3,r0,18 // 0x12
addik r4,r0,52 // 0x34
sw r4,r0,r3
rtsd r15,8
add r3,r0,r0

/* Incorrect */
main()
{
(XIo_Out32(0x12, 0x34));
return 0;
}

addik r3,r0,18 // 0x12
addik r4,r0,52 // 0x34
sw r4,r0,r3
lw r5,r0,r3 // unexpected read!
rtsd r15,8
add r3,r0,r0

Solution

To work around this issue, do not use additional brackets.

AR# 18568
Date Created 12/08/2003
Last Updated 04/28/2006
Status Archive
Type General Article