File: far-hc12.s

package info (click to toggle)
binutils-djgpp 2.35.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 321,256 kB
  • sloc: ansic: 1,162,947; asm: 671,219; cpp: 134,012; exp: 70,783; makefile: 55,860; sh: 22,254; yacc: 14,459; lisp: 13,806; perl: 2,008; lex: 1,649; pascal: 307; sed: 195; awk: 25
file content (83 lines) | stat: -rw-r--r-- 1,430 bytes parent folder | download | duplicates (46)
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
73
74
75
76
77
78
79
80
81
82
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: