This code tests the shift and rotate instructions.


Shell script
Disassembler output

Source: isa2.s

.include "./nios_macros.m"

.global main
.type main, @function

    MOVI32  r2,0x000abc00
    movi    r3,3
    roli   r4,r2,16    # rotate left 16 bit
    srl    r5,r2,r3    # shift right r3 = 3 bits
    sll    r6,r5,r3    # shift left r3 = 3 bits
    slli   r5,r2,12    # shift left 12 bits
    sra    r6,r5,r3    # shift right arithmetic r3 = 3 bits
    srl    r7,r5,r3    # shift right logical
    br     end        /* wait here once the program has completed */

Shell script

nios2-elf-gcc isa2.s
nios2-elf-size a.out
nios2-elf-objdump -dS a.out > isa2.disassemble.txt
nios2-elf-objcopy -S -O binary a.out isa2.bin
nios2-iss -td:isa2.sim.txt --trace-from=main -f a.out

Disassembler output

00000030 <main>:
  30:    008002b4     movhi  r2,10
  34:    10af0014     ori    r2,r2,48128
  38:    00c000c4     movi   r3,3
  3c:    1008143a     roli   r4,r2,16
  40:    10cad83a     srl    r5,r2,r3
  44:    28cc983a     sll    r6,r5,r3
  48:    100a933a     slli   r5,r2,12
  4c:    28cdd83a     sra    r6,r5,r3
  50:    28ced83a     srl    r7,r5,r3

00000054 <end>:
  54:    003fff06     br    54 <end>


0x00000030 <main>:      0x008002b4  movhi r2, 10 [dstData=0xa0000 dstReg=r2]
0x00000034 <main+0x4>:  0x10af0014  ori r2, r2, 48128 [dstData=0xabc00 dstReg=r2]
0x00000038 <main+0x8>:  0x00c000c4  movi r3, 3 [dstData=0x3 dstReg=r3]
0x0000003c <main+0xc>:  0x1008143a  roli r4, r2, 16 [dstData=0xbc00000a dstReg=r4]
0x00000040 <main+0x10>: 0x10cad83a  srl r5, r2, r3 [dstData=0x15780 dstReg=r5]
0x00000044 <main+0x14>: 0x28cc983a  sll r6, r5, r3 [dstData=0xabc00 dstReg=r6]
0x00000048 <main+0x18>: 0x100a933a  slli r5, r2, 12 [dstData=0xabc00000 dstReg=r5]
0x0000004c <main+0x1c>: 0x28cdd83a  sra r6, r5, r3 [dstData=0xf5780000 dstReg=r6]
0x00000050 <main+0x20>: 0x28ced83a  srl r7, r5, r3 [dstData=0x15780000 dstReg=r7]
0x00000054 <end>:       0x003fff06  br 0x54 <end>

Maintained by John Loomis, last updated Fri Apr 06 20:12:58 2007