summaryrefslogtreecommitdiff
path: root/tests/natfeats/nf_asmg.s
blob: bfff265dbf0ce602da265e8b7078d5eb069fa168 (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
/*
 * nf_asm.s - GCC NatFeats ASM detection code
 *
 * Copyright (c) 2014 by Eero Tamminen
 *
 * Mostly based on code from EmuTOS,
 * Copyright (c) 2001-2013 by the EmuTOS development team
 *
 * This file is distributed under the GPL, version 2 or at your
 * option any later version.
 */

/*
 * public interface
 */
        .globl  _nf_id
        .globl  _nf_call
        .globl  _detect_nf

/* illegal exception vector */
        .equ vec_illegal, 0x10

/*
 * code
 */
        .text

/*
 * NatFeats test
 *
 * Needs to be called from Supervisor mode,
 * otherwise exception handler change bombs
 */
_detect_nf:
        clr.l   d0               /* assume no NatFeats available */
        move.l  sp,a1
        move.l  vec_illegal,a0
        move.l  #fail_nf,vec_illegal
        pea     nf_version_name
        sub.l   #4,sp
#ifdef __mcoldfire__
#error Conflict with instruction mvs.b d0,d1
#else
        .dc.w   0x7300              /* Jump to NATFEAT_ID */
#endif
        tst.l   d0
        beq.s   fail_nf
        moveq   #1,d0               /* NatFeats detected */

fail_nf:
        move.l  a1,sp
        move.l  a0,vec_illegal

        rts

nf_version_name:
        .ascii  "NF_VERSION\0"
        .even

/*
 * map native features to NF ID
 */
_nf_id:
        .dc.w   0x7300  /* Conflict with ColdFire instruction mvs.b d0,d1 */
        rts

/*
 * call native feature by its ID
 */
_nf_call:
        .dc.w   0x7301  /* Conflict with ColdFire instruction mvs.b d1,d1 */
        rts