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