Skip to content
Snippets Groups Projects
Commit 4f1e8e36 authored by Ahmad Fares's avatar Ahmad Fares
Browse files

-m updating assembly documentation

parent abd8a7a8
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -17,5 +17,33 @@
<p>Each programming language needs to be translated into the only thing that a CPU or microcontroller understands which is machine code. Assembly uses <strong>assmbler</strong> which converts the <strong>.asm</strong> to <strong>.hex</strong> which can be uploaded to the microcontroller.</p>
<p>I have installed <strong>gavrasm</strong> from this <a href="http://www.avr-asm-tutorial.net/gavrasm/v37/gavrasm_lin_i386_x64_en_37.zip">link</a>, more information can be found in this <a href="http://www.avr-asm-tutorial.net/gavrasm/index_en.html">link</a></p>
<p>After downloading the compiler, I have moved it to the home page of my Ubuntu, so I can use it globally by just calling it from the terminal using the command <code>gavrasm</code> followed by the name of the <strong>.asm</strong> file.</p>
<h2 id="my-first-program">My first program</h2>
<p>In C programming <a href="http://preacademy.fabcloud.io/preacademy2018/participants/fares.ahmad/C-programming/C-programming.html">documentation</a>, I have wrote a simple program which switch an LED when a Button is pressed(PCB design and fabrication can be found in electronics production <a href="http://preacademy.fabcloud.io/preacademy2018/participants/fares.ahmad/electronics/electronics.html">documentation</a>) so I have wrote the same progam in assembly as follows</p>
<pre><code>; buttonled.asm
;
; PreFab Academy
; 21-DEC-2017
; by Ahmad Fares
; MIT License
;
; This program turns on the LED of a helloworld board when the button is pressed
.device attiny44 ; defines which device to assemble for
.org 0 ; sets the programs origin
SBI DDRA,3 ; sbi reg,bit Sets a bit of a register.
; Setting DDRA bit 3 makes pin PA3 a (digital) output
CBI DDRB,2 ; sets PB3 as input
SBI PORTB, 2 ; activates pull up resistor in PB2
loop: ; label for main loop, labels must start with a letter and end with a colon
sbis PINB,2 ; skip the next instruction if PB2 is set (Button)
cbi PORTA,3 ; clear bit PA3 (switch on LED)
sbic PINB,2 ; skip the next instruction if PB2 is clear (Button)
sbi PORTA,3 ; set PA3 (switch off LED)
RJMP done ; jump to done
done:
RJMP loop ; relative jump to label called loop
</code></pre>
</body>
</html>
......@@ -12,4 +12,38 @@ Each programming language needs to be translated into the only thing that a CPU
I have installed **gavrasm** from this [link](http://www.avr-asm-tutorial.net/gavrasm/v37/gavrasm_lin_i386_x64_en_37.zip), more information can be found in this [link](http://www.avr-asm-tutorial.net/gavrasm/index_en.html)
After downloading the compiler, I have moved it to the home page of my Ubuntu, so I can use it globally by just calling it from the terminal using the command `gavrasm` followed by the name of the **.asm** file.
After downloading the compiler, I have moved it to the home page of my Ubuntu, so I can use it globally by just calling it from the terminal using the command `gavrasm` followed by the name of the **.asm** file.
## My first program
In C programming [documentation](http://preacademy.fabcloud.io/preacademy2018/participants/fares.ahmad/C-programming/C-programming.html), I have wrote a simple program which switch an LED when a Button is pressed(PCB design and fabrication can be found in electronics production [documentation](http://preacademy.fabcloud.io/preacademy2018/participants/fares.ahmad/electronics/electronics.html)) so I have wrote the same progam in assembly as follows
```
; buttonled.asm
;
; PreFab Academy
; 21-DEC-2017
; by Ahmad Fares
; MIT License
;
; This program turns on the LED of a helloworld board when the button is pressed
.device attiny44 ; defines which device to assemble for
.org 0 ; sets the programs origin
SBI DDRA,3 ; sbi reg,bit Sets a bit of a register.
; Setting DDRA bit 3 makes pin PA3 a (digital) output
CBI DDRB,2 ; sets PB3 as input
SBI PORTB, 2 ; activates pull up resistor in PB2
loop: ; label for main loop, labels must start with a letter and end with a colon
sbis PINB,2 ; skip the next instruction if PB2 is set (Button)
cbi PORTA,3 ; clear bit PA3 (switch on LED)
sbic PINB,2 ; skip the next instruction if PB2 is clear (Button)
sbi PORTA,3 ; set PA3 (switch off LED)
RJMP done ; jump to done
done:
RJMP loop ; relative jump to label called loop
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment