The famous blink program but this tiome in assembler.
/*
* Atmega2560asmtest.asm
*
* Created: 6/1/2015 3:46:37 PM
* Author: DarkSector
*/
LDI R16, LOW(RAMEND)
OUT SPL, R16
LDI R16, HIGH(RAMEND)
OUT SPH, R16
;MAIN LABEL
MAIN:
LDI R16, 0xFF
OUT DDRB, R16 ;PORTB IS OUTPUT
BACK:
COM R16 ;COMPLEMENT THE VALUE IN R16
OUT PORTB, R16 ;PUSH THE VALUE IN R16 TO PORTB
CALL DELAY
RJMP BACK ;KEEP DOING THIS INFINITELY
DELAY:
LDI R17, 100
LOOP3: LDI R18, 255
LOOP2: LDI R19, 255
LOOP1: DEC R19
BRNE LOOP1 ;KEEP DECREASING R19
DEC R18
BRNE LOOP2 ;FOR EVERY DECREASE OF R18 REDO THE PREVIOUS LOOP
DEC R17
BRNE LOOP3 ;FOR EVERY DECREASE OF R17 REPEAT PREVIOUS LOOP
RET ;RETURN TO PREVIOUS PC ADDRESS
You can also use the inline assembler directly in Arduino IDE.
No comments:
Post a Comment