1;;; Test 68HC12 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-1 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 call _far_no_tramp ; No trampoline generated for _far_no_tramp 31 clra 32 clrb 33 wai 34fail: 35 ldd #1 36 wai 37 bra start 38 39 .sect .bank1,"ax" 40 .globl _far_bar 41 .far _far_bar ; Must mark symbol as far 42_far_bar: 43 jsr local_bank1 44 xgdx 45 rtc 46 47local_bank1: 48 rts 49 50 .sect .bank2,"ax" 51 .globl _far_foo 52 .far _far_foo 53_far_foo: 54 jsr local_bank2 55 rtc 56 57local_bank2: 58 rts 59 60 .sect .bank3,"ax" 61 .globl _far_no_tramp 62 .far _far_no_tramp 63_far_no_tramp: 64 jsr local_bank3 65 rtc 66 67local_bank3: 68 rts 69 70 .sect .text 71 .globl __far_trampoline 72__far_trampoline: 73 movb 0,sp, 2,sp ; Copy page register below the caller's return 74 leas 2,sp ; address. 75 jmp 0,y ; We have a 'call/rtc' stack layout now 76 ; and can jump to the far handler 77 ; (whose memory bank is mapped due to the 78 ; call to the trampoline). 79 80 .sect .bss 81 .skip 100 82stack: 83 84