gavrasm Gerd's AVR assembler version 2.1 (C)2006 by DG4FAC
----------------------------------------------------------
Source file: hello.speaker.45.wave.asm
Hex file:    hello.speaker.45.wave.hex
Eeprom file: hello.speaker.45.wave.eep
Compiled:    14.11.2008, 22:33:27
Pass:        2
     1: ;
     2: ; hello.speaker.45.wave.asm
     3: ;
     4: ; wave-table audio hello-world program
     5: ;
     6: ; Neil Gershenfeld
     7: ; CBA MIT 8/3/07
     8: ;
     9: ; (c) Massachusetts Institute of Technology 2007
    10: ; Permission granted for experimental and personal use;
    11: ; license for commercial sale available from MIT.
    12: ;
    13: .include "tn45def.inc"
 -> Warning 009: Include defs not necessary, using internal values!
   File: hello.speaker.45.wave.asm, Line: 13
   Source line: .include "tn45def.inc"
    14: ; 
    15: ; register definitions
    16: ;
    17: .def temp = R16	; temporary storage
    18: .def temp1 = R17 ; temporary storage
    19: .def sample_count = R18 ; sample counter
    20: .def sample_delay = R19 ; delay between samples
    21: .def delay_count = R20 ; delay loop counter
    22: .def cycle_count = R21 ; cycle counter
    23: .def note_count = R23 ; note counter
    24: .def note_lo = R24 ; note low byte
    25: .def note_hi = R25 ; note high byte
    26: ;
    27: ; code segment
    28: ;
    29: .cseg
    30: .org 0
    31: 000000   C045  rjmp reset
    32: ;
    33: ; waveform
    34: ; first byte = number of samples
    35: ;
    36: wave:
    37:    .db 99,191,195,199,203,207,211,215,218,222
        000001 BF63 C7C3 CFCB D7D3
        000005 DEDA
    38:    .db 225,229,232,235,238,240,243,245,247,249
        000006 E5E1 EBE8 F0EE F5F3
        00000A F9F7
    39:    .db 250,252,253,254,254,254,254,254,254,253
        00000B FCFA FEFD FEFE FEFE
        00000F FDFE
    40:    .db 252,251,250,248,246,244,242,239,236,233
        000010 FBFC F8FA F4F6 EFF2
        000014 E9EC
    41:    .db 230,227,224,220,216,213,209,205,201,197
        000015 E3E6 DCE0 D5D8 CDD1
        000019 C5C9
    42:    .db 193,189,185,181,177,173,169,166,162,158
        00001A BDC1 B5B9 ADB1 A6A9
        00001E 9EA2
    43:    .db 155,152,149,146,143,140,138,136,134,132
        00001F 989B 9295 8C8F 888A
        000023 8486
    44:    .db 131,130,129,128,128,128,128,128,128,129
        000024 8283 8081 8080 8080
        000028 8180
    45:    .db 130,132,133,135,137,139,142,144,147,150
        000029 8482 8785 8B89 908E
        00002D 9693
    46:    .db 153,157,160,164,167,171,175,179,183,187
        00002E 9D99 A4A0 ABA7 B3AF
        000032 BBB7
    47: ;
    48: ; notes
    49: ; first byte = number of notes
    50: ; following notes are specified by the delay between samples
    51: ;   and then the number of cycles
    52: ;
    53: notes:
    54:    .db 18,5,250,5,250,5,250,5,250,5,250,5,250,10,250,10,250,10,250,20,250,20,250,20,250,15,250,30,200,40,100,35,100,35,100,25,200
 -> Warning 004: Number of bytes on line is odd, added 00 to fit program memory!
   File: hello.speaker.45.wave.asm, Line: 54
   Source line:    .db 18,5,250,5,250,5,250,5,250,5,250,5,250,10,250,10,250,10,250,20,250,20,250,20,250,15,250,30,200,40,100,35,100,35,100,25,200
        000033 0512 05FA 05FA 05FA
        000037 05FA 05FA 0AFA 0AFA
        00003B 0AFA 14FA 14FA 14FA
        00003F 0FFA 1EFA 28C8 2364
        000043 2364 1964 00C8
    55: ;
    56: ; main program
    57: ;
    58: reset:	   
    59:    ;
    60:    ; initialization
    61:    ;
    62: 000046   E50F  ldi temp, low(RAMEND)
    63: 000047   BF0D  out SPL, temp ; set stack pointer to top of RAM
    64: 000048   E800  ldi temp, (1<<CLKPCE)
    65: 000049   E010  ldi temp1, ((0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0))
    66: 00004A   BD06  out CLKPR, temp ; write CLKPCE to change clock prescaler
    67: 00004B   BD16  out CLKPR, temp1 ; set clock to 9.6MHz/1
    68: 00004C   E303  ldi temp, ((1 << COM0B0) | (1 << COM0B1) | (1 << WGM01) | (1 << WGM00))
    69: 00004D   BD0A  out TCCR0A, temp ; set OC0B on compare match and set fast PWM mode, 0xFF TOP
    70: 00004E   E001  ldi temp, (1 << CS00)
    71: 00004F   BF03  out TCCR0B, temp ; set timer 0 prescalar to 1
    72: 000050   9AB9  sbi DDRB, PB1 ; enable OC0B output pin
    73: 000051   E33C  ldi sample_delay, 60
    74: 000052   E352  ldi cycle_count, 50
    75:    ;
    76:    ; main loop
    77:    ;
    78:    main_loop:
    79:       ;
    80:       ; read number of notes and set note pointer
    81:       ;
    82: 000053   E6E6  ldi zl, low(notes*2)
    83: 000054   E0F0  ldi zh, high(notes*2)
    84: 000055   95C8  lpm
    85: 000056   2D70  mov note_count, R0
    86: 000057   9631  adiw zl, 1
    87: 000058   01CF  movw note_lo, zl
    88:       ;
    89:       ; loop over notes
    90:       ;
    91: 000059   9573  inc note_count
    92:       note_loop:
    93: 00005A   957A  dec note_count
    94: 00005B   F3B9  breq main_loop
    95: 00005C   01FC  movw zl, note_lo
    96: 00005D   95C8  lpm
    97: 00005E   2D30  mov sample_delay, R0
    98: 00005F   9601  adiw note_lo, 1
    99: 000060   01FC  movw zl, note_lo
   100: 000061   95C8  lpm
   101: 000062   2D50  mov cycle_count, R0
   102: 000063   9601  adiw note_lo, 1
   103: 	 ;
   104: 	 ; loop over cycles
   105: 	 ;
   106: 000064   9553  inc cycle_count
   107: 	 cycle_loop:
   108: 000065   955A  dec cycle_count
   109: 000066   F399  breq note_loop
   110:             ;
   111:             ; read number of samples
   112:             ;
   113: 000067   E0E2  ldi zl, low(wave*2)
   114: 000068   E0F0  ldi zh, high(wave*2)
   115: 000069   95C8  lpm
   116: 00006A   2D20  mov sample_count, R0
   117: 	    ;
   118: 	    ; loop over samples
   119: 	    ;
   120:             sample_loop:
   121: 00006B   9631  adiw zl, 1 ; move to next sample
   122: 00006C   95C8  lpm ; read sample
   123: 00006D   BC08  out OCR0B, R0 ; update PWM
   124: 00006E   2F43  mov delay_count, sample_delay
   125:                sample_delay_loop:
   126: 00006F   954A  dec delay_count
   127: 000070   F7F1  brne sample_delay_loop
   128: 000071   952A  dec sample_count ; decrease sample count
   129: 000072   F7C1  brne sample_loop ; get next sample, ...
   130: 000073   CFF1  rjmp cycle_loop ; ... or repeat cycle if done
   131: 
 -> Warning 001: 1 symbol(s) defined, but not used!

Program             :       47 words.
Constants           :       69 words.
Total program memory:      116 words.
Eeprom space        :        0 bytes.
Data segment        :        0 bytes.
Compilation completed, no errors.
Compilation endet 14.11.2008, 22:33:27
