And if you still want to do it the hard way, you could do something like the following in the Nios command shell:
nios2-elf-gcc -nostdlib -Ttext=0x1000 test.S
elf2hex --input a.out --output test.hex --width 32 --base 0x1000 --end 0x1FFF
The above assumes you have put your source in a file named "test.S" and that your on chip memory starts at 0x1000 and ends at 0x1FFF. You can adjust accordingly. If you assign the resulting test.hex file to on chip memory and set your Nios reset vector to this memory, it should run.
Note that your program should have some kind of loop or something at the end so it doesn't keep executing beyond the end of your source with unpredictable results.