Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

how to get sheer machine code?

Dear NIOS2 Users,

My last post seems to be not in the forum anymore. That's why I post it one more time.

I would like to write code for NIOS2 processor in sheer assembler. Having the code compiled I can store it easily in my on-chip memory.

However, when I try compiling example code:

.section .reset, "ax"

.section .exceptions, "ax"

.global exception_handler

.text

.global _start

_start: /* start function */

br _start

.data

.end

instead of receiving only one jmp opcode (a few bytes) in my output file I receive around 900 bytes.

I compile my code using:

nios2-elf-as -ad %1.s -o a.out

nios2-elf-ld a.out --strip-all --strip-debug -o %1.elf -b binary

For x86 users: I would like to get the same result like using /t with tasm assembler.

Please help me solving the problem. Thank you for your help in advance,

Michał

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    <div class='quotetop'>QUOTE (Koza @ Jul 3 2009, 09:03 AM) <{post_snapback}> (index.php?act=findpost&pid=22998)</div>

    --- Quote Start ---

    Please help me solving the problem. Thank you for your help in advance,[/b]

    --- Quote End ---

    Really no help with the issue? If something is not clear, please let me know. Altera support up to date is helpless...

    Best regards,

    Micha&#322;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    What does nios2-elf-size <your ELF> return? In this case, the size of the ELF (itself) is not really relevant since it contains more than what would be stored in memory.

    Cheers,

    - slacker
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You will need to use nios2-elf-objcopy tool to convert the ELF formatted file into raw machine code. Set the target format to raw. The help and manual for that tool probably contains an example, because that is a common operation.

    Reply if you have problems and the manual doesn&#39;t help enough.