* config/tc-mips.c (append_insn): Correctly handle mips16 case
[binutils.git] / ld / testsuite / ld-m68hc11 / far-hc11.s
blobe8e63d4702b8836bc270680bc653fd7236bf00ff
1 ;;; Test 68HC11 FAR trampoline generation
2 ;;; 2 trampolines are generated:
3 ;;; - one for '_far_bar'
4 ;;; - one for '_far_foo'
5 ;;; 'far_no_tramp' does not have any trampoline generated.
6 ;;;
7 .sect .text
8 .globl _start
9 _start:
10 start:
11 lds #stack
12 ldx #0xabcd
13 pshx
14 ldd #0x1234
15 ldx #0x5678
16 bsr _far_bar ; Call to trampoline generated code
17 cpx #0x1234
18 bne fail ; X and D preserved (swapped by _far_bar)
19 cpd #0x5678
20 bne fail
21 pulx
22 cpx #0xabcd ; Stack parameter preserved
23 bne fail
24 ldd #_far_foo ; Get address of trampoline handler
25 xgdx
26 jsr 0,x
27 ldd #_far_bar ; Likewise (unique trampoline check)
28 xgdy
29 jsr 0,y
30 ldaa #%page(_far_no_tramp)
31 ldy #%addr(_far_no_tramp)
32 bsr __call_a16 ; No trampoline generated for _far_no_tramp
33 clra
34 clrb
35 wai
36 fail:
37 ldd #1
38 wai
39 bra start
40 .global __return
41 __return:
42 ins
43 rts
45 .sect .bank1,"ax"
46 .globl _far_bar
47 .far _far_bar ; Must mark symbol as far
48 _far_bar:
49 jsr local_bank1
50 xgdx
51 jmp __return
53 local_bank1:
54 rts
56 .sect .bank2,"ax"
57 .globl _far_foo
58 .far _far_foo
59 _far_foo:
60 jsr local_bank2
61 jmp __return
63 local_bank2:
64 rts
66 .sect .bank3,"ax"
67 .globl _far_no_tramp
68 .far _far_no_tramp
69 _far_no_tramp:
70 jsr local_bank3
71 jmp __return
73 local_bank3:
74 rts
76 .sect .text
77 .globl __far_trampoline
78 __far_trampoline:
79 psha ; (2) Save function parameter (high)
80 ;; <Read current page in A>
81 psha ; (2)
82 ;; <Set currenge page from B>
83 pshx ; (4)
84 tsx ; (3)
85 ldab 4,x ; (4) Restore function parameter (low)
86 ldaa 2,x ; (4) Get saved page number
87 staa 4,x ; (4) Save it below return PC
88 pulx ; (5)
89 pula ; (3)
90 pula ; (3) Restore function parameter (high)
91 jmp 0,y ; (4)
93 .globl __call_a16
94 __call_a16:
95 ;; xgdx ; (3)
96 ;; <Read current page in A> ; (3) ldaa _current_page
97 psha ; (2)
98 ;; <Set current page from B> ; (4) staa _current_page
99 ;; xgdx ; (3)
100 jmp 0,y ; (4)
102 .sect .page0
103 .skip 100
104 stack: