Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>vectors.s</p> <pre><code>.globl _start _start: mov sp,#0x8000 bl main hang: b hang </code></pre> <p>main.s</p> <pre><code>.globl main main: mov r0,#2 bx lr </code></pre> <p>memmap (linker script)</p> <pre><code>MEMORY { ram : ORIGIN = 0x8000, LENGTH = 0x10000 } SECTIONS { .text : { *(.text*) } &gt; ram .bss : { *(.bss*) } &gt; ram } </code></pre> <p>commands</p> <pre><code>arm-none-eabi-as vectors.s -o vectors.o arm-none-eabi-as main.s -o main.o arm-none-eabi-ld vectors.o main.o -T memmap -o main.elf arm-none-eabi-objdump -D main.elf &gt; main.list arm-none-eabi-objcopy main.elf -O binary main.bin </code></pre> <p>result</p> <pre><code>main.elf: file format elf32-littlearm Disassembly of section .text: 00008000 &lt;_start&gt;: 8000: e3a0d902 mov sp, #32768 ; 0x8000 8004: eb000000 bl 800c &lt;main&gt; 00008008 &lt;hang&gt;: 8008: eafffffe b 8008 &lt;hang&gt; 0000800c &lt;main&gt;: 800c: e3a00002 mov r0, #2 8010: e12fff1e bx lr </code></pre> <p>If you want to use C instead of asm for main then</p> <p>main.c</p> <pre><code>int main ( void ) { return(2); } </code></pre> <p>commands</p> <pre><code>arm-none-eabi-as vectors.s -o vectors.o arm-none-eabi-gcc -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding -c main.c -o main.o arm-none-eabi-ld vectors.o main.o -T memmap -o main.elf arm-none-eabi-objdump -D main.elf &gt; main.list arm-none-eabi-objcopy main.elf -O binary main.bin </code></pre> <p>result</p> <pre><code>main.elf: file format elf32-littlearm Disassembly of section .text: 00008000 &lt;_start&gt;: 8000: e3a0d902 mov sp, #32768 ; 0x8000 8004: eb000000 bl 800c &lt;main&gt; 00008008 &lt;hang&gt;: 8008: eafffffe b 8008 &lt;hang&gt; 0000800c &lt;main&gt;: 800c: e3a00002 mov r0, #2 8010: e12fff1e bx lr </code></pre> <p>I prefer to use a function name other than main because some compilers add extra baggage when they see that function name.</p> <p>vectors.s</p> <pre><code>.globl _start _start: mov sp,#0x8000 bl notmain hang: b hang </code></pre> <p>main.c</p> <pre><code>int notmain ( void ) { return(2); } </code></pre> <p>result</p> <pre><code>main.elf: file format elf32-littlearm Disassembly of section .text: 00008000 &lt;_start&gt;: 8000: e3a0d902 mov sp, #32768 ; 0x8000 8004: eb000000 bl 800c &lt;notmain&gt; 00008008 &lt;hang&gt;: 8008: eafffffe b 8008 &lt;hang&gt; 0000800c &lt;notmain&gt;: 800c: e3a00002 mov r0, #2 8010: e12fff1e bx lr </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload