isa6

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.

The mif file was edited by deleting entries for 0x00 through 0x0b.

Contents

Source
Shell script
Size summary
Sections
Symbols
Disassembler output
Simulation

Source: isa6.s

.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

Shell script

#!/bin/sh
name="isa6"
nios2-elf-gcc ${name}.s
nios2-elf-size a.out > ${name}.size.txt
nios2-elf-objdump -dS a.out > ${name}.disassemble.txt
nios2-elf-objdump -h a.out >  ${name}.headers.txt
nios2-elf-nm a.out > ${name}.symbols.txt
nios2-elf-objcopy -S -O binary a.out ${name}.bin
nios2-iss -td:${name}.sim.txt --trace-from=main -f a.out
mifwrite ${name}.bin ${name}.mif

Size

   text       data        bss        dec        hex    filename
    622        896          0       1518        5ee    a.out

Sections


a.out:     file format elf32-littlenios2

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000026c  00000000  00000000  00000074  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       00000002  0000026c  0000026c  000002e0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data         0000037c  00000270  00000270  000002e2  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .sdata        00000004  000005ec  000005ec  0000065e  2**2
                  CONTENTS, ALLOC, LOAD, DATA, SMALL_DATA
  4 .sbss         00000000  000005f0  000005f0  00000662  2**0
                  CONTENTS, SMALL_DATA
  5 .bss          00000000  000005f0  000005f0  00000662  2**0
                  ALLOC
  6 .comment      00000108  00000000  00000000  00000662  2**0
                  CONTENTS, READONLY
  7 .debug_aranges 000000a0  00000000  00000000  0000076a  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_pubnames 000000d6  00000000  00000000  0000080a  2**0
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_info   00001499  00000000  00000000  000008e0  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_abbrev 000004c2  00000000  00000000  00001d79  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_line   00000a02  00000000  00000000  0000223b  2**0
                  CONTENTS, READONLY, DEBUGGING
 12 .debug_frame  000000e4  00000000  00000000  00002c40  2**2
                  CONTENTS, READONLY, DEBUGGING
 13 .debug_str    0000068a  00000000  00000000  00002d24  2**0
                  CONTENTS, READONLY, DEBUGGING

Symbols

000005f0 A __bss_start
0000023c T __fake_fini
0000006c T __fake_init
00000070 T __start_2
000005f0 A _edata
000005f0 A _end
00000240 T _exit
0000023c W _fini
000085e0 A _gp
000005ec G _impure_ptr
0000006c W _init
00000001 a _nios2_macros_
00000000 T _start
000000b0 T _zero_bss
00000068 t end
000000bc T exit
00000270 d impure_data
00000030 T main
000001a0 T memset
07ffff00 A nasys_stack_top

Disassembler output


a.out:     file format elf32-littlenios2

Disassembly of section .text:

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>

Simulation

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 Oct 29 23:01:56 2008