gavrasm Gerd's AVR assembler version 2.1 (C)2006 by DG4FAC
----------------------------------------------------------
Source file: hello.video.44.asm
Hex file:    hello.video.44.hex
Eeprom file: hello.video.44.eep
Compiled:    14.11.2008, 22:40:04
Pass:        2
     1: ;
     2: ; hello.video.44.asm
     3: ; 
     4: ; NTSC/RS170 video hello-world
     5: ;
     6: ; set fuse low byte to 0x76 for 20 MHz resonator
     7: ;
     8: ; Neil Gershenfeld
     9: ; CBA MIT 11/18/07
    10: ;
    11: ; (c) Massachusetts Institute of Technology 2007
    12: ; Permission granted for experimental and personal use;
    13: ; license for commercial sale available from MIT.
    14: ;
    15: .include "tn44def.inc"
 -> Warning 009: Include defs not necessary, using internal values!
   File: hello.video.44.asm, Line: 15
   Source line: .include "tn44def.inc"
    16: ;
    17: ; definitions
    18: ;
    19: .equ pin_499 = PA7 ; 499 ohm DAC pin
    20: .equ pin_1000 = PA6 ; 1000 ohm DAC pin
    21: ;
    22: ; registers
    23: ;
    24: .def zero = R0 ; 0V
    25: .def black = R1 ; .306V for 499,1k DAC
    26: .def gray = R2 ; .613V for 499,1k DAC
    27: .def white = R3 ; .919V for 499,1k DAC
    28: .def temp = R16 ; temp variable
    29: .def temp1 = R17 ; temp variable
    30: .def row_counter = R18 ; row counter
    31: .def col_counter = R19 ; col counter
    32: ; R30, 31 used for z pointer
    33: ;
    34: ; macros
    35: ;
    36: .macro count
    37:    ;
    38:    ; delay counter
    39:    ;
    40:    ldi temp, @0 ; set match count
    41:    ldi temp1, @1 ;
    42:    out OCR1AH, temp ;
    43:    out OCR1AL, temp1 ;
    44:    clr temp ; clear counter
    45:    out TCNT1H, temp ;
    46:    out TCNT1L, temp ;
    47:    sbi TIFR1, OCF1A ; clear count match flag
    48:    count_loop:
    49:       sbis TIFR1, OCF1A
    50:       rjmp count_loop
    51:    .endmacro
    52: .macro 0V
    53:    ;
    54:    ; output 0V
    55:    ;
    56:    out PORTA, zero
    57:    .endmacro
    58: .macro black
    59:    ;
    60:    ; output black level
    61:    ;
    62:    out PORTA, black
    63:    .endmacro
    64: .macro horizontal_sync
    65:    ;
    66:    ; 4.7us horizontal sync
    67:    ;
    68:    count 0,82
    69:    .endmacro
    70: .macro front_porch
    71:    ;
    72:    ; off-screen beginning of scan line
    73:    ;
    74:    count 0,130
    75:    .endmacro
    76: .macro scan_line
    77:    ;
    78:    ; 58.8us complete scan line
    79:    ;
    80:    count 4,142
    81:    .endmacro
    82: .macro back_porch
    83:    ;
    84:    ; off-screen end of scan line
    85:    ;
    86:    count 0,70
    87:    .endmacro
    88: .macro blank_line
    89:    ;
    90:    ; blank horizontal scan line
    91:    ;
    92:    0V
    93:    horizontal_sync
    94:    black
    95:    scan_line
    96:    .endmacro
    97: .macro sync_line
    98:    ;
    99:    ; vertical sync line
   100:    ;
   101:    ; inverted horizontal sync
   102:    ;
   103:    black
   104:    horizontal_sync
   105:    ;
   106:    ; inverted scan line
   107:    ;
   108:    0V
   109:    scan_line
   110:    .endmacro
   111: ;
   112: ; code segment
   113: ;
   114: .cseg
   115: .org 0
   116: 000000   C000  rjmp reset
   117: ;
   118: ; main program
   119: ;
   120: reset:
   121:    ;
   122:    ; set clock divider to /1
   123:    ;
   124: 000001   E800  ldi temp, (1 << CLKPCE)
   125: 000002   E010  ldi temp1, (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0)
   126: 000003   BD06  out CLKPR, temp
   127: 000004   BD16  out CLKPR, temp1
   128:    ; 
   129:    ; set counter prescaler to /1
   130:    ;
   131: 000005   E001  ldi temp, (1 << CS10)
   132: 000006   BD0E  out TCCR1B, temp
   133:    ;
   134:    ; set stack pointer to top of RAM
   135:    ;
   136: 000007   E001  ldi temp, high(RAMEND)
   137: 000008   BF0E  out SPH, temp
   138: 000009   E50F  ldi temp, low(RAMEND)
   139: 00000A   BF0D  out SPL, temp
   140:    ;
   141:    ; init DAC pins
   142:    ;
   143: 00000B   98DF  cbi PORTA, pin_499
   144: 00000C   9AD7  sbi DDRA, pin_499
   145: 00000D   98DE  cbi PORTA, pin_1000
   146: 00000E   9AD6  sbi DDRA, pin_1000
   147:    ;
   148:    ; set DAC value registers
   149:    ;
   150: 00000F   E000  ldi temp, 0
   151: 000010   2E00  mov zero, temp
   152: 000011   E400  ldi temp, (1 << pin_1000)
   153: 000012   2E10  mov black, temp
   154: 000013   E800  ldi temp, (1 << pin_499)
   155: 000014   2E20  mov gray, temp
   156: 000015   EC00  ldi temp, ((1 << pin_499) | (1 << pin_1000))
   157: 000016   2E30  mov white, temp
   158:    ;
   159:    ; store test pattern in SRAM
   160:    ;
   161: 000017   E6E0  ldi zl, low(SRAM_START)
   162: 000018   E0F0  ldi zh, high(SRAM_START)
   163: 000019   E238  ldi col_counter, 40
   164:    store_loop:
   165: 00001A   9211  st z+, black
   166: 00001B   9221  st z+, gray
   167: 00001C   9211  st z+, black
   168: 00001D   9231  st z+, white
   169: 00001E   953A  dec col_counter
   170: 00001F   F7D1  brne store_loop
   171:    ;
   172:    ; start main loop
   173:    ;
   174:    main_loop:
   175:       ;
   176:       ; 242 63.5us horizontal scan lines
   177:       ;
   178: 000020   EF22  ldi row_counter, 242
   179:       row_loop:
   180:          0V
   181: 	 horizontal_sync
   182: 	 black
   183: 	 front_porch
   184: 	 ;
   185: 	 ; set z to point to test pattern
   186: 	 ;
   187: 000037   E6E0  ldi zl, low(SRAM_START)
   188: 000038   E0F0  ldi zh, high(SRAM_START)
   189: 	 ;
   190: 	 ;  column loop
   191: 	 ;
   192: 000039   EA30  ldi col_counter, 160
   193: 	 col_loop:
   194: 00003A   9101  ld temp, z+
   195: 00003B   BB0B  out PORTA, temp
   196: 00003C   953A  dec col_counter
   197: 00003D   F7E1  brne col_loop
   198:  	 black
   199: 	 back_porch
   200: 000049   952A  dec row_counter
   201: 00004A   F009  breq row_loop_continue
   202: 00004B   CFD5  rjmp row_loop
   203:       row_loop_continue:
   204:       ;
   205:       ; 5 black lines
   206:       ;
   207: 00004C   E025  ldi row_counter, 5
   208:       black_loop:
   209:          0V
   210: 	 horizontal_sync
   211:          black
   212: 	 scan_line
   213: 000063   952A  dec row_counter
   214: 000064   F741  brne black_loop
   215:       ;
   216:       ; 3 vertical sync lines
   217:       ;
   218: 000065   E023  ldi row_counter, 3
   219:       sync_loop:
   220:          sync_line
   221: 00007C   952A  dec row_counter
   222: 00007D   F741  brne sync_loop
   223:       ;
   224:       ; 12 black lines
   225:       ;
   226: 00007E   E02C  ldi row_counter, 12
   227:       black_loop1:
   228:          0V
   229: 	 horizontal_sync
   230:          black
   231: 	 scan_line
   232: 000095   952A  dec row_counter
   233: 000096   F741  brne black_loop1
   234:       ;
   235:       ; 60Hz main loop
   236:       ;
   237: 000097   CF88  rjmp main_loop
   238: 

Program             :      152 words.
Constants           :        0 words.
Total program memory:      152 words.
Eeprom space        :        0 bytes.
Data segment        :        0 bytes.
Compilation completed, no errors.
Compilation endet 14.11.2008, 22:40:04
