Created
June 20, 2014 16:10
-
-
Save JoshTGreenwood/cab6f61e6160579ea10f to your computer and use it in GitHub Desktop.
Assembly Code To Read In From Ports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* midterm.asm | |
* | |
* Created: 6/20/2014 11:41:46 AM | |
* Author: Josh | |
*/ | |
.org 0x0 | |
ldi r30,0x00 | |
ldi r31,0x10 | |
// sets PORTC and PORTE data direction to read | |
sts PORTC_DIR, r30 | |
sts PORTE_DIR, r30 | |
// loads the contents of PORTC and PORTE to r16 and r17 | |
lds r16, PORTC_IN | |
lds r17, PORTE_IN | |
// adds r17 to r16 | |
add r16,r17 | |
// conditionally turn on led if carry flag is set | |
brcs turnLedOn | |
setPORTR: | |
// sets PORTR data direction to write | |
sts PORTR_DIR, r31 | |
// writes the contents of r16 to PORTR | |
sts PORTR_OUT, r16 | |
label: rjmp label | |
turnLedOn: | |
// sets PORTF data direction to write | |
sts PORTF_DIR, r31 | |
// turns led on | |
sts PORTF_OUT, r31 | |
rjmp setPORTR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment