title: Sine wave using one register
body: <p>So I was tasked with creating a sine wave I came up with this which uses two registers and works...</p>
  
  <pre><code> DAC    EQU 0600h   ;DAC memory mapped at address 600h
  tbl_len EQU 24  ;length of sine wave table
  
      ORG 8100H       ;start of program
  
  sine:   mov R7, #tbl_len    ;initialise table counter
      mov R6, #0  ;initialise table pointer
  
  sloop:  mov dptr, #table    ;load dptr with address of table
      mov a, R6   ;load acc with table pointer
      movc    a, @a+dptr  ;read from table + table pointer
  
      mov dptr, #DAC  ;load dptr with 0600 DAC base address
      movx    @dptr, a    ;Output table value from DAC
      acall   delay
      inc R6  ;inc table pointer
      djnz    R7, sloop   ;dec table counter until zero
      sjmp  sine  ;Repeat loop
  
  delay:  mov R0, #11
  loop:   djnz    R0, dloop   ;go around this loop 11 times
      ret
  
  table:  DB  1,5,18,38,65,95,128,161,192,218,238,251
      DB  255,251,238,218,192,161,128,95,65,38,18,5
  </code></pre>
  
  <p>Now I have been asked to use only one register. I am a little confused even though I get the sense that it might be quite a simple solution. Any hints would be great.</p>