aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/samples/cop0-test-ia.S
blob: 9badb92fdc02e9ab2538bc1f298192cf6467b5fb (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Directives to make interresting windows visible
#pragma qtmips show terminal
#pragma qtmips show registers
#pragma qtmips show cop0dock
#pragma qtmips show memory

.set SERIAL_PORT_BASE,     0xffffc000

.set SERP_RX_ST_REG_o,           0x00
.set SERP_RX_ST_REG_READY_m,      0x1
.set SERP_RX_ST_REG_IE_m,         0x2

.set SERP_RX_DATA_REG_o,         0x04

.set SERP_TX_ST_REG_o,           0x08
.set SERP_TX_ST_REG_READY_m,      0x1
.set SERP_TX_ST_REG_IE_m,         0x2

.set SERP_TX_DATA_REG_o,         0x0c

.globl _start
.set noat
.set noreorder
.ent _start

.text

_start:
	addi	$1, $0, 0x101
	addi	$2, $0, 0x102
	synci	0($zero)
	addi	$3, $0, 0x103
	addi	$4, $0, 0x104
	la	$20, skip
	mtc0	$20, $14, 0  // EPC
	eret
	addi	$5, $0, 0x105
	addi	$6, $0, 0x106
skip:
	addi	$7, $0, 0x107
	addi	$8, $0, 0x108
	mfc0	$9, $14, 0   // EPC

	break
	mfc0	$10, $14, 0  // EPC

	la	$20, irq_entry - 0x180
	mtc0	$20, $15, 1  // EBase

	li	$21, SERIAL_PORT_BASE
	li	$20, SERP_RX_ST_REG_IE_m
	sw	$20, SERP_RX_ST_REG_o($21)
	li	$20, 0x00000801
	mtc0	$20, $12, 0  // Status

loop:	mfc0	$10, $14, 0  // EPC
	beq	$zero, $zero, loop
	nop


irq_entry:
	mfc0	$26, $13, 0  // Cause
	andi	$27, $26, 0x00000800
	bne	$27, $0, rx_irq
	nop
	mfc0	$27, $12, 0  // Status
	nor	$26, $26, $0
	andi	$26, $26, 0x0000ff00
	and	$27, $27, $26
	mtc0	$27, $12, 0  // Status
	eret

rx_irq:
	li	$26, SERIAL_PORT_BASE
	lw	$27, SERP_RX_DATA_REG_o($26)
	sw	$27, SERP_TX_DATA_REG_o($26)
	eret

.end _start

// if whole source compile is OK the switch to core tab
#pragma qtmips tab core