Debian Codegraph @

examples/prism-asmatmel.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>; This is a comment</code></pre>
3
4 <h2>Labels</h2>
5 <pre><code>label1: ; a label</code></pre>
6
7 <h2>Opcodes</h2>
8 <pre><code>LD
9 OUT
10
11 ; lowercase
12 ldi
13 jmp label1
14 </code></pre>
15
16 <h2>Assembler directives</h2>
17 <pre><code>.segment CODE
18 .word $07d3
19 </code></pre>
20
21 <h2>Registers</h2>
22 <pre><code>LD A ; "A"
23 LDA label1,x ; "x"
24 </code></pre>
25
26 <h2>Strings</h2>
27 <pre><code>.include "header.asm"
28 </code></pre>
29
30 <h2>Numbers</h2>
31 <pre><code>ldi r24,#127
32 ldi r24,$80f0
33 ldi r24,#%01011000
34 </code></pre>
35
36 <h2>Constants</h2>
37 <pre><code>ldi r16, (0&lt;&lt;PB5)|(1&lt;&lt;PB4)|(1&lt;&lt;PB3)|(1&lt;&lt;PB2)|(1&lt;&lt;PB1)|(1&lt;&lt;PB0)</code></pre>
38
39 <h2>Example program to light up LEDs</h2>
40 <h3>Attach an LED (through a 220 ohm resistor) to any of the pins 0-12</h3>
41 <pre><code>; Pin Constant Values (Tested on Arduino UNO)
42 ; PD0 - 0
43 ; PD1 - 1
44 ; PD2 - 2
45 ; PD3 - 3
46 ; PD4 - 4
47 ; PD5 - 5
48 ; PD6 - 6
49 ; PD7 - 7
50
51 ; PB0 - 8
52 ; PB1 - 9
53 ; PB2 - 10
54 ; PB3 - 11
55 ; PB4 - 12
56 ; PB5 - 13 - System LED
57
58 start:
59
60 ; Set pins 0-7 to high
61 ldi r17, (1&lt;&lt;PD7)|(1&lt;&lt;PD6)|(1&lt;&lt;PD5)|(1&lt;&lt;PD4)|(1&lt;&lt;PD3)|(1&lt;&lt;PD2)|(1&lt;&lt;PD1)|(1&lt;&lt;PD0)
62 out PORTD, r17
63
64 ; Set pins 8-13 to high
65 ldi r16, (1&lt;&lt;PB5)|(1&lt;&lt;PB4)|(1&lt;&lt;PB3)|(1&lt;&lt;PB2)|(1&lt;&lt;PB1)|(1&lt;&lt;PB0)
66 out PORTB, r16
67
68 ; Set pins 0-7 to output mode
69 ldi r18, (1&lt;&lt;DDD7)|(1&lt;&lt;DDD6)|(1&lt;&lt;DDD5)|(1&lt;&lt;DDD4)|(1&lt;&lt;DDD3)|(1&lt;&lt;DDD2)|(1&lt;&lt;DDD1)|(1&lt;&lt;DDD0)
70 out DDRD, r18
71
72 ; Set pins 8-13 to output mode
73 ldi r19, (1&lt;&lt;DDB5)|(1&lt;&lt;DDB4)|(1&lt;&lt;DDB3)|(1&lt;&lt;DDB2)|(1&lt;&lt;DDB1)|(1&lt;&lt;DDB0)
74 out DDRB, r19
75
76 loop:
77 rjmp loop ; loop forever
78 </code></pre>