xref: /netbsd/sys/arch/m68k/060sp/dist/ilsp.doc (revision 6550d01e)
1#
2# $NetBSD: ilsp.doc,v 1.1 2000/04/14 20:24:39 is Exp $
3#
4
5#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6# MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
7# M68000 Hi-Performance Microprocessor Division
8# M68060 Software Package Production Release
9#
10# M68060 Software Package Copyright (C) 1993, 1994, 1995, 1996 Motorola Inc.
11# All rights reserved.
12#
13# THE SOFTWARE is provided on an "AS IS" basis and without warranty.
14# To the maximum extent permitted by applicable law,
15# MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
16# INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS
17# FOR A PARTICULAR PURPOSE and any warranty against infringement with
18# regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
19# and any accompanying written materials.
20#
21# To the maximum extent permitted by applicable law,
22# IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
23# (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
24# BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS)
25# ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
26#
27# Motorola assumes no responsibility for the maintenance and support
28# of the SOFTWARE.
29#
30# You are hereby granted a copyright license to use, modify, and distribute the
31# SOFTWARE so long as this entire notice is retained without alteration
32# in any modified and/or redistributed versions, and that such modified
33# versions are clearly identified as such.
34# No licenses are granted by implication, estoppel or otherwise under any
35# patents or trademarks of Motorola, Inc.
36#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37
3868060 INTEGER SOFTWARE PACKAGE (Library version)
39-------------------------------------------------
40
41The file ilsp.s contains the "Library version" of the
4268060 Integer Software Package. Routines included in this
43module can be used to emulate 64-bit divide and multiply,
44and the "cmp2" instruction. These instructions are not
45implemented in hardware on the 68060 and normally take
46exception vector #61 "Unimplemented Integer Instruction".
47
48By re-compiling a program that uses these instructions, and
49making subroutine calls in place of the unimplemented
50instructions, a program can avoid the overhead associated with
51taking the exception.
52
53Release file format:
54--------------------
55The file ilsp.sa is essentially a hexadecimal image of the
56release package. This is the ONLY format which will be supported.
57The hex image was created by assembling the source code and
58then converting the resulting binary output image into an
59ASCII text file. The hexadecimal numbers are listed
60using the Motorola Assembly Syntax assembler directive "dc.l"
61(define constant longword). The file can be converted to other
62assembly syntaxes by using any word processor with a global
63search and replace function.
64
65To assist in assembling and linking this module with other modules,
66the installer should add a symbolic label to the top of the file.
67This will allow calling routines to access the entry points
68of this package.
69
70The source code ilsp.s has also been included but only for
71documentation purposes.
72
73Release file structure:
74-----------------------
75The file ilsp.sa contains an "Entry-Point" section and a
76code section. The ILSP has no "Call-Out" section. The first section
77is the "Entry-Point" section. In order to access a function in the
78package, a program must "bsr" or "jsr" to the location listed
79below in "68060ILSP Entry Points" that corresponds to the desired
80function. A branch instruction located at the selected entry point
81within the package will then enter the correct emulation code routine.
82
83The entry point addresses at the beginning of the package will remain
84fixed so that a program calling the routines will not have to be
85re-compiled with every new 68060ILSP release.
86
87For example, to use a 64-bit multiply instruction,
88do a "bsr" or "jsr" to the entry point defined by
89the 060ILSP entry table. A compiler generated code sequence
90for unsigned multiply could look like:
91
92# mulu.l <ea>,Dh:Dl
93# mulu.l _multiplier,%d1:%d0
94
95	subq.l	&0x8,%sp	# make room for result on stack
96	pea	(%sp)		# pass: result addr on stack
97	mov.l	%d0,-(%sp)	# pass: multiplicand on stack
98	mov.l	_multiplier,-(%sp) # pass: multiplier on stack
99	bsr.l	_060LISP_TOP+0x18 # branch to multiply routine
100	add.l	&0xc,%sp	# clear arguments from stack
101	mov.l	(%sp)+,%d1	# load result[63:32]
102	mov.l	(%sp)+,%d0	# load result[31:0]
103
104For a divide:
105
106# divu.l <ea>,Dr:Dq
107# divu.l _divisor,%d1:%d0
108
109	subq.l	&0x8,%sp	# make room for result on stack
110	pea	(%sp)		# pass: result addr on stack
111	mov.l	%d0,-(%sp)	# pass: dividend hi on stack
112	mov.l	%d1,-(%sp)	# pass: dividend hi on stack
113	mov.l	_divisor,-(%sp) # pass: divisor on stack
114	bsr.l	_060LISP_TOP+0x08 # branch to divide routine
115	add.l	&0xc,%sp	# clear arguments from stack
116	mov.l	(%sp)+,%d1	# load remainder
117	mov.l	(%sp)+,%d0	# load quotient
118
119The library routines also return the correct condition code
120register value. If this is important, then the caller of the library
121routine must make sure that the value isn't lost while popping
122other items off of the stack.
123
124An example of using the "cmp2" instruction is as follows:
125
126# cmp2.l <ea>,Rn
127# cmp2.l _bounds,%d0
128
129	pea	_bounds		# pass ptr to bounds
130	mov.l	%d0,-(%sp)	# pass Rn
131	bsr.l	_060LSP_TOP_+0x48 # branch to "cmp2" routine
132	mov.w	%cc,_tmp	# save off condition codes
133	addq.l	&0x8,%sp	# clear arguments from stack
134
135Exception reporting:
136--------------------
137If the instruction being emulated is a divide and the source
138operand is a zero, then the library routine, as it's last
139instruction, executes an implemented divide using a zero
140source operand so that an "Integer Divide-by-Zero" exception
141will be taken. Although the exception stack frame will not
142point to the correct instruction, the user will at least be able
143to record that such an event occurred if desired.
144
14568060ILSP entry points:
146-----------------------
147_060ILSP_TOP:
1480x000:	_060LSP__idivs64_
1490x008:	_060LSP__idivu64_
150
1510x010:	_060LSP__imuls64_
1520x018:	_060LSP__imulu64_
153
1540x020:	_060LSP__cmp2_Ab_
1550x028:	_060LSP__cmp2_Aw_
1560x030:	_060LSP__cmp2_Al_
1570x038:	_060LSP__cmp2_Db_
1580x040:	_060LSP__cmp2_Dw_
1590x048:	_060LSP__cmp2_Dl_
160