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: 10start: 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 36fail: 37 ldd #1 38 wai 39 bra start 40 .global __return 41__return: 42 ins 43 rts 44 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 52 53local_bank1: 54 rts 55 56 .sect .bank2,"ax" 57 .globl _far_foo 58 .far _far_foo 59_far_foo: 60 jsr local_bank2 61 jmp __return 62 63local_bank2: 64 rts 65 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 72 73local_bank3: 74 rts 75 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) 92 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) 101 102 .sect .page0 103 .skip 100 104stack: 105 106