title: Problems combining SDCC and ASM code compiling on the Intel 8051
body: <p>We are trying to compile our C code which includes a lot of assembly for various operations (timing, producing output waveforms, and measuring input frequency). </p>
  
  <p>We keep getting the same error for a few of our ASM operations:</p>
  
  <p>".org in REL area or directive / mnemonic error" </p>
  
  <p>In our code below, we get 3 errors (i commented on which lines they happen, and what exactly the error we get is. Thanks!</p>
  
  <pre><code>void getFrequency(int *freqHi, int *freqLo) 
  {
      __asm
      ;
      ; A program that measures the frequency at pin T0 (P1.2)
  
      ljmp GetFreq
  
      Wait1s:
          mov R2, #40
      M3: mov R1, #250
      M2: mov R0, #181
      M1: djnz R0, M1 ; 2 machine cycles-&gt; 2*0.27126us*181=100us
          djnz R1, M2 ; 100us*250=0.025s
          djnz R2, M3 ; 0.025s*40=1s
          ret
  
      ;Initializes timer/counter 0 as a 16-bit counter
      InitTimer0:
          setb T0 ; Enable pin T0 as input
          clr TR0 ; Stop timer 0
          mov a,#0F0H ; ERROR &lt;o&gt; .org in REL area or directive / mnemonic error
          anl a,TMOD
          orl a,#00000101B ; Set timer 0 as 16-bit counter ERROR &lt;o&gt; .org in REL area or directive / mnemonic error
          mov TMOD,a
          ret
  
      GetFreq:
          mov SP, #7FH ; Set the stack pointer to the begining of idata ERROR &lt;o&gt; .org in REL area or directive / mnemonic error
  
          lcall InitTimer0
  
          clr TR0 ; Stop counter 0
          mov TL0, #0
          mov TH0, #0
  
          setb TR0 ; Start counting
          lcall Wait1s ; Wait one second
          clr TR0 ; Stop counter 0, TH0-TL0 has the frequency
  
          mov R0, TH0
          mov R1, TL0
  
          mov _freqHi, R0
          mov _freqLo, R1
  
      __endasm;
  
      // freqHi, freqLo have respective values
  }
  </code></pre>