This code tests the compare instructions.


Shell script
Disassembler output

Source: isa3.s

.include "./nios_macros.m"

.global main
.type main, @function

    movi    r2,48
    movi    r3,55
    cmplt   r4,r2,r3
    cmpne   r5,r2,r3
    cmpge   r6,r3,r2
    cmpeqi  r4,r2,48
    cmpgei  r5,r2,33
    cmpnei  r6,r3,55
    sub     r3,r2,r3
    movi    r4,37
    sub     r2,r4,r2
    cmplt   r4,r2,r3
    cmpne   r5,r2,r3
    cmpge   r6,r3,r2
    cmpltu  r4,r2,r3
    cmpgeu  r5,r2,r3
    movi32  r2,-6
    movi32  r3,-18
    cmpgeui r5,r3,0x8abc
    br      end        /* wait here once the program has completed */

Shell script

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

Disassembler output

00000030 <main>:
  30:    00800c04     movi    r2,48
  34:    00c00dc4     movi    r3,55
  38:    10c8803a     cmplt    r4,r2,r3
  3c:    10cac03a     cmpne    r5,r2,r3
  40:    188c403a     cmpge    r6,r3,r2
  44:    11000c20     cmpeqi    r4,r2,48
  48:    11400848     cmpgei    r5,r2,33
  4c:    19800dd8     cmpnei    r6,r3,55
  50:    10c7c83a     sub    r3,r2,r3
  54:    01000944     movi    r4,37
  58:    2085c83a     sub    r2,r4,r2
  5c:    10c8803a     cmplt    r4,r2,r3
  60:    10cac03a     cmpne    r5,r2,r3
  64:    188c403a     cmpge    r6,r3,r2
  68:    10c9803a     cmpltu    r4,r2,r3
  6c:    10cb403a     cmpgeu    r5,r2,r3
  70:    00bffff4     movhi    r2,65535
  74:    10bffe94     ori    r2,r2,65530
  78:    00fffff4     movhi    r3,65535
  7c:    18fffb94     ori    r3,r3,65518
  80:    1962af28     cmpgeui    r5,r3,35516

00000084 <end>:
  84:    003fff06     br    84 <end>


0x00000030 <main>:      0x00800c04  movi r2, 48 [dstData=0x30 dstReg=r2]
0x00000034 <main+0x4>:  0x00c00dc4  movi r3, 55 [dstData=0x37 dstReg=r3]
0x00000038 <main+0x8>:  0x10c8803a  cmplt r4, r2, r3 [dstData=0x1 dstReg=r4]
0x0000003c <main+0xc>:  0x10cac03a  cmpne r5, r2, r3 [dstData=0x1 dstReg=r5]
0x00000040 <main+0x10>: 0x188c403a  cmpge r6, r3, r2 [dstData=0x1 dstReg=r6]
0x00000044 <main+0x14>: 0x11000c20  cmpeqi r4, r2, 48 [dstData=0x1 dstReg=r4]
0x00000048 <main+0x18>: 0x11400848  cmpgei r5, r2, 33 [dstData=0x1 dstReg=r5]
0x0000004c <main+0x1c>: 0x19800dd8  cmpnei r6, r3, 55 [dstData=0x0 dstReg=r6]
0x00000050 <main+0x20>: 0x10c7c83a  sub r3, r2, r3 [dstData=0xfffffff9 dstReg=r3]
0x00000054 <main+0x24>: 0x01000944  movi r4, 37 [dstData=0x25 dstReg=r4]
0x00000058 <main+0x28>: 0x2085c83a  sub r2, r4, r2 [dstData=0xfffffff5 dstReg=r2]
0x0000005c <main+0x2c>: 0x10c8803a  cmplt r4, r2, r3 [dstData=0x1 dstReg=r4]
0x00000060 <main+0x30>: 0x10cac03a  cmpne r5, r2, r3 [dstData=0x1 dstReg=r5]
0x00000064 <main+0x34>: 0x188c403a  cmpge r6, r3, r2 [dstData=0x1 dstReg=r6]
0x00000068 <main+0x38>: 0x10c9803a  cmpltu r4, r2, r3 [dstData=0x1 dstReg=r4]
0x0000006c <main+0x3c>: 0x10cb403a  cmpgeu r5, r2, r3 [dstData=0x0 dstReg=r5]
0x00000070 <main+0x40>: 0x00bffff4  movhi r2, 65535 [dstData=0xffff0000 dstReg=r2]
0x00000074 <main+0x44>: 0x10bffe94  ori r2, r2, 65530 [dstData=0xfffffffa dstReg=r2]
0x00000078 <main+0x48>: 0x00fffff4  movhi r3, 65535 [dstData=0xffff0000 dstReg=r3]
0x0000007c <main+0x4c>: 0x18fffb94  ori r3, r3, 65518 [dstData=0xffffffee dstReg=r3]
0x00000080 <main+0x50>: 0x1962af28  cmpgeui r5, r3, 35516 [dstData=0x1 dstReg=r5]
0x00000084 <end>:       0x003fff06  br 0x84 <end>

Maintained by John Loomis, last updated Fri Apr 06 20:07:38 2007