aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/d30v-elf/tick.s
blob: d834ca7af9b3f032b17b360571b3e2db09b5f9fb (plain)
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
43
44
45
46
47
48
49
50
51
	.globl _start
	#
	# NOTE:	Registers r10-r11 are reserved for the interrupt handler
	#	while the others can be used by the main loop/start code.

_start:		
	# patch the external interrupt handlers entry
	add r1, r0, handler
	ldw r2, @(r1, 0)
	ldw r3, @(r1, 4)
	add r1, r0, 0xfffff138
	stw r2, @(r1, 0)
	stw r3, @(r1, 4)
	
	# enable external interrupts - cr0 == PSW
	mvfsys r2, cr0
	or r2, r0, 0x04000000
	mvtsys cr0, r2


	# wait for flag to be set
loop:	
	add r2, r0, flag
	ldw r3, @(r2, 0)
	bratzr r3, loop

	# clear the flag
	stw r0, @(r2, 0)

	add r2, r0, tick
	# putstr
	.long 0x0e000001, 0x00f00000

	bra loop

	# finished
	add r2, r0, r0 || nop
	.long 0x0e000004, 0x00f00000

	
handler:
	jmp real_handler
real_handler:
	add r10, r0, 1
	add r11, r0, flag
	stb r10, @(r11,0)
	reit


flag:	.long 0
tick:	.ascii "Tick\r\n"