Download: isa6.zip
This code uses stw and ldw instructions, referenced to the stack or frame pointer. The stack pointer is set explicity and then copied to the frame pointer. This means that there are no references to memory other than through the stack.
.include "./nios_macros.m" .text .global main .type main, @function main: movi sp,0xffc addi sp,sp,-64 stw ra,60(sp) stw fp,56(sp) mov fp,sp movi r4,24 stw r4,8(fp) movi r4,19 stw r4,4(fp) ldw r3,8(fp) ldw r5,4(fp) add r4,r3,r5 stw r4,0(fp) ldw fp,56(sp) end: br end /* wait here once the program has completed */ .end
#!/bin/sh nios2-elf-gcc isa6.s nios2-elf-size a.out > isa6.size.txt nios2-elf-objdump -dS a.out > isa6.disassemble.txt nios2-elf-objdump -h a.out > isa6.headers.txt nios2-elf-nm a.out > isa6.symbols.txt nios2-elf-objcopy -S -O binary a.out isa6.bin nios2-iss -td:sim6.txt --trace-from=main -f a.out
text data bss dec hex filename 622 896 0 1518 5ee a.out
00000030 <main>: 30: 06c3ff04 movi sp,4092 34: defff004 addi sp,sp,-64 38: dfc00f15 stw ra,60(sp) 3c: df000e15 stw fp,56(sp) 40: d839883a mov fp,sp 44: 01000604 movi r4,24 48: e1000215 stw r4,8(fp) 4c: 010004c4 movi r4,19 50: e1000115 stw r4,4(fp) 54: e0c00217 ldw r3,8(fp) 58: e1400117 ldw r5,4(fp) 5c: 1949883a add r4,r3,r5 60: e1000015 stw r4,0(fp) 64: df000e17 ldw fp,56(sp) 00000068 <end>: 68: 003fff06 br 68 <end>
0x00000030 <main>: 0x06c3ff04 movi sp, 4092 [dstData=0xffc dstReg=sp] 0x00000034 <main+0x4>: 0xdefff004 addi sp, sp, -64 [dstData=0xfbc dstReg=sp] 0x00000038 <main+0x8>: 0xdfc00f15 stw ra, 60(sp) [memAddr=0xff8 stData=0xa8] 0x0000003c <main+0xc>: 0xdf000e15 stw fp, 56(sp) [memAddr=0xff4 stData=0xdeadbeef] 0x00000040 <main+0x10>: 0xd839883a mov fp, sp [dstData=0xfbc dstReg=fp] 0x00000044 <main+0x14>: 0x01000604 movi r4, 24 [dstData=0x18 dstReg=r4] 0x00000048 <main+0x18>: 0xe1000215 stw r4, 8(fp) [memAddr=0xfc4 stData=0x18] 0x0000004c <main+0x1c>: 0x010004c4 movi r4, 19 [dstData=0x13 dstReg=r4] 0x00000050 <main+0x20>: 0xe1000115 stw r4, 4(fp) [memAddr=0xfc0 stData=0x13] 0x00000054 <main+0x24>: 0xe0c00217 ldw r3, 8(fp) [memAddr=0xfc4 ldData=0x18 dstReg=r3] 0x00000058 <main+0x28>: 0xe1400117 ldw r5, 4(fp) [memAddr=0xfc0 ldData=0x13 dstReg=r5] 0x0000005c <main+0x2c>: 0x1949883a add r4, r3, r5 [dstData=0x2b dstReg=r4] 0x00000060 <main+0x30>: 0xe1000015 stw r4, 0(fp) [memAddr=0xfbc stData=0x2b] 0x00000064 <main+0x34>: 0xdf000e17 ldw fp, 56(sp) [memAddr=0xff4 ldData=0xdeadbeef dstReg=fp] 0x00000068 <end>: 0x003fff06 br 0x68 <end>
Maintained by John Loomis, last updated Wed Apr 11 09:49:03 2007