Specifications

Embedded System Tools Guide (EDK 6.2i) www.xilinx.com 175
UG111 (v1.4) January 30, 2004 1-800-255-7778
MicroBlaze GNU Compiler
R
where mytargetlabel is the label of the target instruction. The mb-as assembler computes
the immediate value of the instruction as mytargetlabel - PC. If this immediate value
is greater than 16 bits, the mb-assembler automatically inserts an imm instruction. If the
value of mytargetlabel is not known at the time of compilation, the mb-as assembler
always inserts an imm instruction. The
relax option of the linker should be used to
remove any imm instructions that are found to be unnecessary.
Similarly, if an instruction needs a large constant as an operand, the assembly language
programmer should use the operand as-is, without using an imm instruction. For example,
the following code is used to add the constant 200,000 to the contents of register r3, and
store the result in register r4:
addi r4, r3, 200000
The mb-assembler will recognize that this operand needs an imm instruction, and insert
one automatically.
In addition to the standard MicroBlaze instruction set, the mb-as assembler also supports
some pseudo-opcodes to ease the task of assembly programming. The supported pseudo-
ops are listed in Table 11-7.
MicroBlaze Linker
The mb-ld linker for Xilinx’s MicroBlaze soft processor introduces some new options in
addition to those supported by the gnu compiler tools. The new options are summarized in
this section.
-defsym _TEXT_START_ADDR=value
By default, the text section of the output code starts with the base address 0x0. This can be
overridden by using the above options. If this is supplied to mb-gcc, the text section of the
output code will now start from the given value. When the compiler is invoked with -xl-
mode-xmdstub, the user program starts at 0x400 by default.
The user does not have to use -defsym _TEXT_START_ADDR, if they wish to use the
default start address set by the compiler.
This is a linker option and should be used when the user is invoking the linker separately.
If the linker is being invoked as a part of the mb-gcc flow, the user has to use the following
option
-Wl,-defsym -Wl,_TEXT_START_ADDR=value
Table 11-7: Pseudo-Opcodes supported by the Gnu Assembler
Pseudo Opcodes Explanation
nop No operation. Replaced by instruction:
or R0, R0, R0
la Rd, Ra, Imm Replaced by instruction:
addik Rd, Ra, imm; = Rd = Ra + Imm;
not Rd, Ra Replace by instruction: xori Rd, Ra, -1
neg Rd, Ra Replace by instruction: rsub Rd, Ra, R0
sub Rd, Ra, Rb Replace by instruction: rsub Rd, Rb, Ra