Forum Discussion
Altera_Forum
Honored Contributor
21 years agoCompiler
http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/mad.gif
movia at,((90057600)/115200) 28: 00400034 movhi at,0 2c: 0840c354 ori at,at,781 movia at,((90000000+57600)/115200) 30: 00415774 movhi at,1373 34: 0852a014 ori at,at,190726 Replies
- Altera_Forum
Honored Contributor
I just tried assembling the following code:
with the command line:.set noat movia at,((90000000+57600)/115200)
And got a pair of instructions which load up the value 781 (decimal). Which version of the tools are you using?nios2-elf-gcc -c -o test.o test.s nios2-elf-objdump -S test.o - Altera_Forum
Honored Contributor
Test code as following:# ====================================
.set noat _start: movia at,((90000000+57600)/115200) movia at,((90057600)/115200) .end# ==================================== I got these result: [NIOS2 GNU Shell]$ nios2-elf-gcc -c -o test.o test.S [NIOS2 GNU Shell]$ nios2-elf-objdump -S test.o test.o: file format elf32-littlenios2 Disassembly of section .text: 00000000 <_start>: 0: 00415774 movhi at,1373 4: 0852a014 ori at,at,19072 8: 00400034 movhi at,0 c: 0840c354 ori at,at,781 [NIOS2 GNU Shell]$ Why? - Altera_Forum
Honored Contributor
but , got the result with these cmd line:
[NIOS2 GNU Shell]$ nios2-elf-as -o test.o test.S [NIOS2 GNU Shell]$ nios2-elf-objdump -S test.o test.o: file format elf32-littlenios2 Disassembly of section .text: 00000000 <_start>: 0: 00400034 movhi at,0 4: 0840c344 addi at,at,781 8: 00400034 movhi at,0 c: 0840c344 addi at,at,781 /cygdrive/g/nios2/src/boot_loader [NIOS2 GNU Shell]$ - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by simon.embed@Mar 16 2005, 10:01 AM test code as following:# ====================================.set noat
_start:
movia at,((90000000+57600)/115200)
movia at,((90057600)/115200)
.end# ====================================
i got these result:
[nios2 gnu shell]$ nios2-elf-gcc -c -o test.o test.s
[nios2 gnu shell]$ nios2-elf-objdump -s test.o
test.o: file format elf32-littlenios2
disassembly of section .text:
00000000 <_start>:
0: 00415774 movhi at,1373
4: 0852a014 ori at,at,19072
8: 00400034 movhi at,0
c: 0840c354 ori at,at,781
[nios2 gnu shell]$
why? --- Quote End --- What version are you running? If you type nios2-elf-gcc -v this will tell you. Using your file .set noat _start: movia at,((90000000+57600)/115200) movia at,((90057600)/115200) .end With the command lines below I get exactly what you'd expect [SOPC Builder]$ nios2-elf-gcc -c -o test.o test.S /cygdrive/d [SOPC Builder]$ nios2-elf-objdump -S test.o test.o: file format elf32-littlenios2 Disassembly of section .text: 00000000 <_start>: 0: 00400034 movhi at,0 4: 0840c344 addi at,at,781 8: 00400034 movhi at,0 c: 0840c344 addi at,at,781
- Altera_Forum
Honored Contributor
Thanks, rugbybloke. I got it. I have included some head file(#include "macros.h") in source file, which get wrong. Instruction MOVIA was redefined in that head file!
- Altera_Forum
Honored Contributor
maybe the compiler bug for the following test code:# test.S# define ALT_CPU_FREQ 90000000# define BAUD_RATE 2400 //1200# define C_DIVISOR ((ALT_CPU_FREQ+BAUD_RATE/2)/BAUD_RATE)
.equ A_DIVISOR , ((ALT_CPU_FREQ+BAUD_RATE/2)/BAUD_RATE) .macro MOVUIK32 _reg,_val .if (\_val >>16) == 0 MOVUI \_reg,%lo(\_val) .elseif (\_val <<16) == 0 MOVHI \_reg,%hi(\_val) .else MOVIA \_reg,\_val .endif .endm .section .text .align 2 .set noat _start: MOVUIK32 r2,C_DIVISOR MOVUIK32 r3,A_DIVISOR .end You may change the valu of ALT_CPU_FREQ and BAUD_RATE macros, and then check the compiling result!