aimless debugging, forgot -m68000 in the linker command line
[lugburz] / src / amiga / intr.s
1 | vi:filetype=gas68k:
2         .section .text
3
4         .equ DMACON, 0x002
5         .equ VPOSR, 0x004
6         .equ VHPOSR, 0x006
7         .equ COLOR0, 0x180
8
9         .global exc_init
10 exc_init:
11         move.l #exc_addr, 0xc
12         rts
13
14         .global exc_addr
15 exc_addr:
16         ori.w #0x700, %sr
17         move.l #0xdff000, %a0
18         move.w #0x7fff, DMACON(%a0)     | clear all DMACON bits
19
20         move.l #str_exc3beg, -(%sp)
21         jsr ser_print
22         add.l #4, %sp
23
24         move.l 2(%sp), %d0
25         move.l %d0, -(%sp)
26         bsr print_hex
27         add.l #4, %sp
28
29         move.l #str_exc3end, -(%sp)
30         jsr ser_print
31         add.l #4, %sp
32
33         move.l #3, -(%sp)
34
35 colbars_infloop:
36         move.l #0xdff000, %a0
37         move.w #0, COLOR0(%a0)
38         move.b #128, %d1
39         move.l (%sp), %d2
40
41 0:      move.b VHPOSR(%a0), %d0
42         cmp.b %d1, %d0
43         bne.s 0b
44         add.b #4, %d1
45         move.w #0xfff, COLOR0(%a0)
46 1:      move.b VHPOSR(%a0), %d0
47         cmp.b %d1, %d0
48         bne.s 1b
49         add.b #8, %d1
50         move.w #0, COLOR0(%a0)
51         sub.b #1, %d2
52         bne.s 0b
53
54 0:      cmp.b #0xff, VHPOSR(%a0)
55         bne.s 0b
56         bra.s colbars_infloop
57
58 print_hex:
59         move.l #hexbuf, %a0
60         move.l 4(%sp), %d0
61         move.l #8, %d3
62 0:      rol.l #4, %d0
63         move.b %d0, %d1
64         and.b #0xf, %d1
65         cmp.b #10, %d1
66         bhs.s 1f
67         add.b #'0', %d1         | d1 is in [0, 9]
68         bra.s 2f
69 1:      add.b #'a'-10, %d1      | d1 is in [10, 15]
70 2:      move.b %d1, (%a0)+
71         sub.l #1, %d3
72         bne.s 0b
73
74         move.b #0, (%a0)+
75         move.l #hexbuf, -(%sp)
76         jsr ser_print
77         add.l #4, %sp
78         rts
79
80 hexbuf: .fill 16
81 str_exc3beg: .asciz "Exception 3: address error ("
82 str_exc3end: .asciz ")\n"