File: test_stack.asm

package info (click to toggle)
simulavr 0.1.2.2-6.1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 2,756 kB
  • ctags: 3,179
  • sloc: ansic: 19,987; sh: 3,623; python: 3,528; makefile: 406; asm: 308; yacc: 145; lex: 48
file content (42 lines) | stat: -rw-r--r-- 1,375 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;
; $Id: test_stack.asm,v 1.3 2001/10/15 18:52:00 troth Exp $
;
; Test pushing 4 bytes onto the stack. When done, expect to see:
	;; last 4 bytes of sram with 00, 01, 02, 03
	;; SPH, SPL with 0x02, 0x5b
	;; SREG -> 0x02
;.device         AT90S8515

.include        "8515def.inc"

        rjmp    MAIN            ; reset
        nop                     ; int0
        nop                     ; int1
        nop                     ; timer1 capt
        nop                     ; timer1 compa
        nop                     ; timer1 compb
        nop                     ; timer1 ovf
        nop                     ; timer0 ovf
        nop                     ; spi, stc
        nop                     ; uart, rx
        nop                     ; uart, udre
        nop                     ; uart, tx
        nop                     ; ana_comp

MAIN:
	;; init stack pointer to 0x025f (the last byte of int sram)
		ldi		r16, lo8(RAMEND); low byte of end of int sram
		out		SPL, r16
		ldi		r16, hi8(RAMEND); high byte of end of int sram
		out		SPH, r16

	;; push 4 numbers onto the stack (use r16 as a counter)
		ldi		r16, 0x03
PUSH_EM:
		push	r16				; push r16 onto the stack, should inc SP
		cpi		r16, 0x00		; compare r16 with $00, should set sreg
		breq	PUSHED_ALL		; branch to end if sreg['Z'] == 1
		dec		r16				; decrment r16
		rjmp	PUSH_EM			; repeat
PUSHED_ALL:	
		nop