* ld-m68hc11/far-hc11.s: New file.
authorStephane Carrez <stcarrez@nerim.fr>
Mon, 21 Apr 2003 13:30:14 +0000 (13:30 +0000)
committerStephane Carrez <stcarrez@nerim.fr>
Mon, 21 Apr 2003 13:30:14 +0000 (13:30 +0000)
* ld-m68hc11/far-hc11.d: New test for HC11 trampoline generation.
* ld-m68hc11/far-hc12.s: New file.
* ld-m68hc11/far-hc12.d: New test for HC12 trampoline generation.
* ld-m68hc11/far-hc12.ld: New file.

ld/testsuite/ChangeLog
ld/testsuite/ld-m68hc11/far-hc11.d [new file with mode: 0644]
ld/testsuite/ld-m68hc11/far-hc11.s [new file with mode: 0644]
ld/testsuite/ld-m68hc11/far-hc12.d [new file with mode: 0644]
ld/testsuite/ld-m68hc11/far-hc12.ld [new file with mode: 0644]
ld/testsuite/ld-m68hc11/far-hc12.s [new file with mode: 0644]

index 70ab6718e282a50d39b0a3c959568bcf9f5595e4..ec6c50c4ffb6eaa8b2e4126ccafc949cfddfbb8d 100644 (file)
@@ -1,3 +1,11 @@
+2003-04-21  Stephane Carrez  <stcarrez@nerim.fr>
+
+       * ld-m68hc11/far-hc11.s: New file.
+       * ld-m68hc11/far-hc11.d: New test for HC11 trampoline generation.
+       * ld-m68hc11/far-hc12.s: New file.
+       * ld-m68hc11/far-hc12.d: New test for HC12 trampoline generation.
+       * ld-m68hc11/far-hc12.ld: New file.
+
 2003-04-15  H.J. Lu <hjl@gnu.org>
 
        * ld-elfcom/elfcom.exp: Fix a typo.
diff --git a/ld/testsuite/ld-m68hc11/far-hc11.d b/ld/testsuite/ld-m68hc11/far-hc11.d
new file mode 100644 (file)
index 0000000..e380511
--- /dev/null
@@ -0,0 +1,73 @@
+#source: far-hc11.s
+#as: -m68hc11
+#ld: -m m68hc11elf
+#objdump: -d --prefix-addresses -r
+#target: m6811-*-* m6812-*-*
+
+.*:     file format elf32-m68hc11
+
+Disassembly of section .text:
+0+8000 <tramp._far_foo> pshb
+0+8001 <tramp._far_foo\+0x1> ldab      \#0
+0+8003 <tramp._far_foo\+0x3> ldy       \#0+6c <_far_foo>
+0+8007 <tramp._far_foo\+0x7> jmp       0+8056 <__far_trampoline>
+0+800a <tramp._far_bar> pshb
+0+800b <tramp._far_bar\+0x1> ldab      \#0
+0+800d <tramp._far_bar\+0x3> ldy       \#0+64 <stack>
+0+8011 <tramp._far_bar\+0x7> jmp       0+8056 <__far_trampoline>
+0+8014 <_start> lds    \#0+64 <stack>
+0+8017 <_start\+0x3> ldx       \#0+abcd <__data_image\+0x2b63>
+0+801a <_start\+0x6> pshx
+0+801b <_start\+0x7> ldd       \#0+1234 <__data_section_start\+0x134>
+0+801e <_start\+0xa> ldx       \#0+5678 <__data_section_start\+0x4578>
+0+8021 <_start\+0xd> jsr       0+800a <tramp._far_bar>
+0+8024 <_start\+0x10> cpx      \#0+1234 <__data_section_start\+0x134>
+0+8027 <_start\+0x13> bne      0+804e <fail>
+0+8029 <_start\+0x15> cpd      \#0+5678 <__data_section_start\+0x4578>
+0+802d <_start\+0x19> bne      0+804e <fail>
+0+802f <_start\+0x1b> pulx
+0+8030 <_start\+0x1c> cpx      \#0+abcd <__data_image\+0x2b63>
+0+8033 <_start\+0x1f> bne      0+804e <fail>
+0+8035 <_start\+0x21> ldd      \#0+8000 <tramp._far_foo>
+0+8038 <_start\+0x24> xgdx
+0+8039 <_start\+0x25> jsr      0,x
+0+803b <_start\+0x27> ldd      \#0+800a <tramp._far_bar>
+0+803e <_start\+0x2a> xgdy
+0+8040 <_start\+0x2c> jsr      0,y
+0+8043 <_start\+0x2f> ldaa     \#0
+0+8045 <_start\+0x31> ldy      \#0+73 <_far_no_tramp>
+0+8049 <_start\+0x35> bsr      0+8066 <__call_a16>
+0+804b <_start\+0x37> clra
+0+804c <_start\+0x38> clrb
+0+804d <_start\+0x39> wai
+0+804e <fail> ldd      \#0+1 <__bss_size\+0x1>
+0+8051 <fail\+0x3> wai
+0+8052 <fail\+0x4> bra 0+8014 <_start>
+0+8054 <__return> ins
+0+8055 <__return\+0x1> rts
+0+8056 <__far_trampoline> psha
+0+8057 <__far_trampoline\+0x1> psha
+0+8058 <__far_trampoline\+0x2> pshx
+0+8059 <__far_trampoline\+0x3> tsx
+0+805a <__far_trampoline\+0x4> ldab    4,x
+0+805c <__far_trampoline\+0x6> ldaa    2,x
+0+805e <__far_trampoline\+0x8> staa    4,x
+0+8060 <__far_trampoline\+0xa> pulx
+0+8061 <__far_trampoline\+0xb> pula
+0+8062 <__far_trampoline\+0xc> pula
+0+8063 <__far_trampoline\+0xd> jmp     0,y
+0+8066 <__call_a16> psha
+0+8067 <__call_a16\+0x1> jmp   0,y
+Disassembly of section .bank1:
+0+64 <_far_bar> jsr    0+6b <local_bank1>
+0+67 <_far_bar\+0x3> xgdx
+0+68 <_far_bar\+0x4> jmp       0+8054 <__return>
+0+6b <local_bank1> rts
+Disassembly of section .bank2:
+0+6c <_far_foo> jsr    0+72 <local_bank2>
+0+6f <_far_foo\+0x3> jmp       0+8054 <__return>
+0+72 <local_bank2> rts
+Disassembly of section .bank3:
+0+73 <_far_no_tramp> jsr       0+79 <local_bank3>
+0+76 <_far_no_tramp\+0x3> jmp  0+8054 <__return>
+0+79 <local_bank3> rts
diff --git a/ld/testsuite/ld-m68hc11/far-hc11.s b/ld/testsuite/ld-m68hc11/far-hc11.s
new file mode 100644 (file)
index 0000000..e8e63d4
--- /dev/null
@@ -0,0 +1,105 @@
+;;; Test 68HC11 FAR trampoline generation
+;;; 2 trampolines are generated:
+;;; - one for '_far_bar'
+;;; - one for '_far_foo'
+;;; 'far_no_tramp' does not have any trampoline generated.
+;;;
+       .sect .text
+       .globl _start
+_start:
+start: 
+       lds     #stack
+       ldx     #0xabcd
+       pshx
+       ldd     #0x1234
+       ldx     #0x5678
+       bsr     _far_bar        ; Call to trampoline generated code
+       cpx     #0x1234
+       bne     fail            ; X and D preserved (swapped by _far_bar)
+       cpd     #0x5678
+       bne     fail
+       pulx
+       cpx     #0xabcd         ; Stack parameter preserved
+       bne     fail
+       ldd     #_far_foo       ; Get address of trampoline handler
+       xgdx
+       jsr     0,x
+       ldd     #_far_bar       ; Likewise (unique trampoline check)
+       xgdy
+       jsr     0,y
+       ldaa    #%page(_far_no_tramp)
+       ldy     #%addr(_far_no_tramp)
+       bsr     __call_a16      ; No trampoline generated for _far_no_tramp
+       clra
+       clrb
+       wai
+fail:
+       ldd     #1
+       wai
+       bra     start
+       .global __return
+__return:
+       ins
+       rts
+
+       .sect .bank1,"ax"
+       .globl _far_bar
+       .far _far_bar           ; Must mark symbol as far
+_far_bar:
+       jsr     local_bank1
+       xgdx
+       jmp     __return
+
+local_bank1:
+       rts
+
+       .sect .bank2,"ax"
+       .globl _far_foo
+       .far _far_foo
+_far_foo:
+       jsr     local_bank2
+       jmp     __return
+
+local_bank2:
+       rts
+
+       .sect .bank3,"ax"
+       .globl _far_no_tramp
+       .far _far_no_tramp
+_far_no_tramp:
+       jsr     local_bank3
+       jmp     __return
+
+local_bank3:
+       rts
+
+       .sect .text
+       .globl __far_trampoline
+__far_trampoline:
+       psha                            ; (2) Save function parameter (high)
+       ;; <Read current page in A>
+       psha                            ; (2)
+       ;; <Set currenge page from B>
+       pshx                            ; (4)
+       tsx                             ; (3)
+       ldab    4,x                     ; (4) Restore function parameter (low)
+       ldaa    2,x                     ; (4) Get saved page number
+       staa    4,x                     ; (4) Save it below return PC
+       pulx                            ; (5)
+       pula                            ; (3)
+       pula                            ; (3) Restore function parameter (high)
+       jmp     0,y                     ; (4)
+
+       .globl __call_a16
+__call_a16:
+       ;; xgdx                         ; (3)
+       ;; <Read current page in A>     ; (3) ldaa _current_page
+       psha                            ; (2)
+       ;; <Set current page from B>    ; (4) staa _current_page
+       ;; xgdx                         ; (3)
+       jmp 0,y                         ; (4)
+
+       .sect .page0
+       .skip 100
+stack:
+
diff --git a/ld/testsuite/ld-m68hc11/far-hc12.d b/ld/testsuite/ld-m68hc11/far-hc12.d
new file mode 100644 (file)
index 0000000..304ae87
--- /dev/null
@@ -0,0 +1,55 @@
+#source: far-hc12.s
+#as: -m68hc12
+#ld: -m m68hc12elf --script $srcdir/$subdir/far-hc12.ld
+#objdump: -d --prefix-addresses -r
+#target: m6811-*-* m6812-*-*
+
+.*:     file format elf32\-m68hc12
+
+Disassembly of section .text:
+0+c000 <tramp\._far_foo> ldy   \#0+8000 <__bank_start>
+0+c003 <tramp\._far_foo\+0x3> call     0+c049 <__far_trampoline> \{0+c049 <__far_trampoline>, 1\}
+0+c007 <tramp\._far_bar> ldy   \#0+8000 <__bank_start>
+0+c00a <tramp\._far_bar\+0x3> call     0+c049 <__far_trampoline> \{0+c049 <__far_trampoline>, 0\}
+0+c00e <_start> lds    \#0+2063 <stack-0x1>
+0+c011 <_start\+0x3> ldx       \#0+abcd <__bank_start\+0x2bcd>
+0+c014 <_start\+0x6> pshx
+0+c015 <_start\+0x7> ldd       \#0+1234 <stack\-0xe30>
+0+c018 <_start\+0xa> ldx       \#0+5678 <__bank_size\+0x1678>
+0+c01b <_start\+0xd> jsr       0+c007 <tramp._far_bar>
+0+c01e <_start\+0x10> cpx      \#0+1234 <stack\-0xe30>
+0+c021 <_start\+0x13> bne      0+c043 <fail>
+0+c023 <_start\+0x15> cpd      \#0+5678 <__bank_size\+0x1678>
+0+c026 <_start\+0x18> bne      0+c043 <fail>
+0+c028 <_start\+0x1a> pulx
+0+c029 <_start\+0x1b> cpx      \#0+abcd <__bank_start\+0x2bcd>
+0+c02c <_start\+0x1e> bne      0+c043 <fail>
+0+c02e <_start\+0x20> ldd      \#0+c000 <tramp._far_foo>
+0+c031 <_start\+0x23> xgdx
+0+c033 <_start\+0x25> jsr      0,X
+0+c035 <_start\+0x27> ldd      \#0+c007 <tramp._far_bar>
+0+c038 <_start\+0x2a> xgdy
+0+c03a <_start\+0x2c> jsr      0,Y
+0+c03c <_start\+0x2e> call     0+18000 <_far_no_tramp> \{0+8000 <__bank_start>, 2\}
+0+c040 <_start\+0x32> clra
+0+c041 <_start\+0x33> clrb
+0+c042 <_start\+0x34> wai
+0+c043 <fail> ldd      \#0+1 <stack\-0x2063>
+0+c046 <fail\+0x3> wai
+0+c047 <fail\+0x4> bra 0+c00e <_start>
+0+c049 <__far_trampoline> movb 0,SP, 2,SP
+0+c04d <__far_trampoline\+0x4> leas    2,SP
+0+c04f <__far_trampoline\+0x6> jmp     0,Y
+Disassembly of section .bank1:
+0+10+ <_far_bar> jsr   0+10006 <local_bank1>
+0+10003 <_far_bar\+0x3> xgdx
+0+10005 <_far_bar\+0x5> rtc
+0+10006 <local_bank1> rts
+Disassembly of section .bank2:
+0+14000 <_far_foo> jsr 0+14004 <local_bank2>
+0+14003 <_far_foo\+0x3> rtc
+0+14004 <local_bank2> rts
+Disassembly of section .bank3:
+0+18000 <_far_no_tramp> jsr    0+18004 <local_bank3>
+0+18003 <_far_no_tramp\+0x3> rtc
+0+18004 <local_bank3> rts
diff --git a/ld/testsuite/ld-m68hc11/far-hc12.ld b/ld/testsuite/ld-m68hc11/far-hc12.ld
new file mode 100644 (file)
index 0000000..78dffe6
--- /dev/null
@@ -0,0 +1,18 @@
+ENTRY(_start)
+SECTIONS {
+  .text 0xc000 : {
+    *(.text)
+  }
+  .bank1 0x10000 : {
+    *(.bank1)
+  }
+  .bank2 0x14000 : {
+    *(.bank2)
+  }
+  .bank3 0x18000 : {
+    *(.bank3)
+  }
+  .bss 0x2000 : {
+    *(.bss)
+  }
+}
diff --git a/ld/testsuite/ld-m68hc11/far-hc12.s b/ld/testsuite/ld-m68hc11/far-hc12.s
new file mode 100644 (file)
index 0000000..0081e38
--- /dev/null
@@ -0,0 +1,83 @@
+;;; Test 68HC12 FAR trampoline generation
+;;; 2 trampolines are generated:
+;;; - one for '_far_bar'
+;;; - one for '_far_foo'
+;;; 'far_no_tramp' does not have any trampoline generated.
+;;;
+       .sect .text
+       .globl _start
+_start:
+start: 
+       lds     #stack-1
+       ldx     #0xabcd
+       pshx
+       ldd     #0x1234
+       ldx     #0x5678
+       bsr     _far_bar        ; Call to trampoline generated code
+       cpx     #0x1234
+       bne     fail            ; X and D preserved (swapped by _far_bar)
+       cpd     #0x5678
+       bne     fail
+       pulx
+       cpx     #0xabcd         ; Stack parameter preserved
+       bne     fail
+       ldd     #_far_foo       ; Get address of trampoline handler
+       xgdx
+       jsr     0,x
+       ldd     #_far_bar       ; Likewise (unique trampoline check)
+       xgdy
+       jsr     0,y
+       call    _far_no_tramp   ; No trampoline generated for _far_no_tramp
+       clra
+       clrb
+       wai
+fail:
+       ldd     #1
+       wai
+       bra     start
+
+       .sect .bank1,"ax"
+       .globl _far_bar
+       .far _far_bar           ; Must mark symbol as far
+_far_bar:
+       jsr     local_bank1
+       xgdx
+       rtc
+
+local_bank1:
+       rts
+
+       .sect .bank2,"ax"
+       .globl _far_foo
+       .far _far_foo
+_far_foo:
+       jsr     local_bank2
+       rtc
+
+local_bank2:
+       rts
+
+       .sect .bank3,"ax"
+       .globl _far_no_tramp
+       .far _far_no_tramp
+_far_no_tramp:
+       jsr     local_bank3
+       rtc
+
+local_bank3:
+       rts
+
+       .sect .text
+       .globl __far_trampoline
+__far_trampoline:
+       movb    0,sp, 2,sp      ; Copy page register below the caller's return
+       leas    2,sp            ; address.
+       jmp     0,y             ; We have a 'call/rtc' stack layout now
+                               ; and can jump to the far handler
+                               ; (whose memory bank is mapped due to the
+                               ; call to the trampoline).
+
+       .sect .bss
+       .skip 100
+stack:
+