File: prism-asmatmel.html

package info (click to toggle)
node-prismjs 1.30.0%2Bdfsg%2B~1.26.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,220 kB
  • sloc: javascript: 27,628; makefile: 9; sh: 7; awk: 4
file content (78 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<h2>Comments</h2>
<pre><code>; This is a comment</code></pre>

<h2>Labels</h2>
<pre><code>label1:   ; a label</code></pre>

<h2>Opcodes</h2>
<pre><code>LD
OUT

; lowercase
ldi
jmp label1
</code></pre>

<h2>Assembler directives</h2>
<pre><code>.segment CODE
.word $07d3
</code></pre>

<h2>Registers</h2>
<pre><code>LD A  ; "A"
LDA label1,x  ; "x"
</code></pre>

<h2>Strings</h2>
<pre><code>.include "header.asm"
</code></pre>

<h2>Numbers</h2>
<pre><code>ldi r24,#127
ldi r24,$80f0
ldi r24,#%01011000
</code></pre>

<h2>Constants</h2>
<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>

<h2>Example program to light up LEDs</h2>
<h3>Attach an LED (through a 220 ohm resistor) to any of the pins 0-12</h3>
<pre><code>; Pin Constant Values (Tested on Arduino UNO)
; PD0 - 0
; PD1 - 1
; PD2 - 2
; PD3 - 3
; PD4 - 4
; PD5 - 5
; PD6 - 6
; PD7 - 7

; PB0 - 8
; PB1 - 9
; PB2 - 10
; PB3 - 11
; PB4 - 12
; PB5 - 13 - System LED

start:

	; Set pins 0-7 to high
	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)
	out		PORTD, r17

	; Set pins 8-13 to high
	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)
	out		PORTB, r16

	; Set pins 0-7 to output mode
	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)
	out		DDRD, r18

	; Set pins 8-13 to output mode
	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)
	out		DDRB, r19

loop:
	rjmp loop ; loop forever
</code></pre>