Created
March 15, 2012 11:39
-
-
Save inkrement/2043800 to your computer and use it in GitHub Desktop.
AVR Stack Addition
This file contains 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
; Christian Hotz-Behofsits 2012 | |
; Simple AVRASM Test - take all values from the Stack, add them and print to PORTA | |
.NOLIST | |
.INCLUDE "m1280def.inc" | |
.LIST | |
.section .text | |
.org 0x0000 | |
Reset: | |
rjmp main | |
add_stack: | |
out PORTB, R17 ;print old value | |
pop R19 | |
add R17, R19 | |
out PORTA, R17 ;print new value | |
rjmp loop | |
main: | |
clr R17 ;R17 init | |
;output init | |
ser R21 | |
out DDRA, R21 | |
out DDRB, R21 | |
;init stack | |
ldi R18, lo8(RAMEND) | |
out SPL, R18 | |
ldi r18, hi8(RAMEND) | |
out SPH, r18 | |
;push | |
ldi R20, 0x01 | |
push R20 | |
ldi R20, 0x04 | |
push R20 | |
ldi R20, 0x01 | |
push R20 | |
loop: | |
ldi R18, lo8(RAMEND) | |
in R16, SPL | |
CP R18, R16 | |
ldi R18, hi8(RAMEND) | |
in R16, SPH | |
CPC R18, R16 | |
brne add_stack | |
rjmp loop | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment