I have an Arduino Uno Rev3 and I'm calling the following assembly function from the main code in C.
#
# Global data (val1)
#
.extern delay
.data
.comm val1,1
.global val1
#
# Program code (compute function)
#
.text
.global compute
compute:
lds r22, val1 ;value of input
ldi r23, 0x00 ;0 value
ldi r24, 0x0D ;value to flash led
flash:
# flash LED
call SDelay ;Short Delay
out 0x04, r24 ;LED On
out 0x05, r24
call SDelay ;Delay
out 0x04, r23 ;LED Off
out 0x05, r23
dec r22
brne flash;
finish:
rjmp finish ;keep looping once finished
SDelay:
# Push registers onto stack
push r22
push r23
push r24
push r25
#Delay
ldi r22, 0xa0
ldi r23, 0x00
ldi r24, 0x00
ldi r25, 0x00
call delay
#Pop registers on stack
pop r25
pop r24
pop r23
pop r22
ret
This is supposed to flash an LED (I'm unsure which one I am flashing here) the number of times inputed. This number of times should be stored in val1 (calculated in C). However, I don't know what I'm doing wrong.
And can someone quickly explain how to flash the specific LEDs in the arduino board? I know I have to set a pin to high or low, but I don't know which pin will do that for the specific LED.
I know these are noob questions, but I'm new to AVR assembly and really suck at it. I wouldn't do it this way but the CS department at our school deems it necessary for us to understand this.
Thanks!