[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] FreeMiNT for ColdFire: XaAES



Vincent Rivière wrote:
Rename the files:
- xaaes/src.km/xa_user_things.s
- xaaes/src.km/nkcc-gc.s
with a capital .S extension.

And finally, the xaaesv4e.km patch!
Please apply this patch after the above changes.

After that, xaaesv4e.km will be 100% ColdFire.
This works flawlessly on FireTOS/FireBee.

And a benefit to all the other targets: previously, some parts of xaaes.km were always compiled for a bare 68000. Now it is fully optimized for its target: full 68030, etc. :-)

Alan, please commit! (after the rename above)

Added ColdFire support. Contributed by Vincent Riviere.

--
Vincent Rivière
diff -x CVS -aurN freemint.orig/xaaes/src.km/Makefile.objs freemint/xaaes/src.km/Makefile.objs
--- freemint.orig/xaaes/src.km/Makefile.objs	2011-04-02 16:38:59.906250000 +0200
+++ freemint/xaaes/src.km/Makefile.objs	2011-05-15 20:40:25.175875000 +0200
@@ -29,21 +29,6 @@
 	-Wshadow \
 	-Wpointer-arith
 
-NOCFLAGS-adiload.c = $(MODEL)
-CFLAGS-adiload.c = -m68000
-NOCFLAGS-draw_obj.c = $(MODEL)
-CFLAGS-draw_obj.c = -m68000
-NOCFLAGS-info.c = $(MODEL)
-CFLAGS-info.c = -m68000
-NOCFLAGS-mvdi.c = $(MODEL)
-CFLAGS-mvdi.c = -m68000
-NOCFLAGS-nkcc-gc.S = $(MODEL)
-CFLAGS-nkcc-gc.S = -m68000
-NOCFLAGS-nkcc-gc.s = $(MODEL)
-CFLAGS-nkcc-gc.s = -m68000
-NOCFLAGS-xa_user_things.s = $(MODEL)
-CFLAGS-xa_user_things.s = -m68000
-
 LD = $(CC) -nostdlib -Wl,--entry -Wl,_init
 LIBS = -lgem $(LIBKERN) -lgcc
 STRIPFLAGS =
diff -x CVS -aurN freemint.orig/xaaes/src.km/adiload.c freemint/xaaes/src.km/adiload.c
--- freemint.orig/xaaes/src.km/adiload.c	2011-03-13 09:47:00.843750000 +0100
+++ freemint/xaaes/src.km/adiload.c	2011-05-16 00:19:12.004000000 +0200
@@ -52,14 +52,14 @@
 
 	__asm__ volatile
 	(
-		"movem.l d3-d7/a3-a6,-(sp);"
-		"move.l %4,-(sp);"
-		"move.l	%3,-(sp);"
-		"move.l	%2,-(sp);"
-		"move.l	%1,a0;"
-		"jsr	(a0);"
-		"lea	12(sp),sp;"
-		"movem.l (sp)+,d3-d7/a3-a6;"
+		PUSH_SP("d3-d7/a3-a6", 36)
+		"move.l	%4,-(sp)\n\t"
+		"move.l	%3,-(sp)\n\t"
+		"move.l	%2,-(sp)\n\t"
+		"move.l	%1,a0\n\t"
+		"jsr	(a0)\n\t"
+		"lea	12(sp),sp\n\t"
+		POP_SP("d3-d7/a3-a6", 36)
 		: "=r"(ret)					/* outputs */
 		: "g"(initfunc), "r"(k), "r"(a), "g"(reason)	/* inputs  */
 		: __CLOBBER_RETURN("d0")
@@ -122,15 +122,15 @@
 
 	__asm__ volatile
 	(
-		"movem.l d3-d7/a3-a6,-(sp);"
-		"move.l %5,-(sp);"
-		"move.l %4,-(sp);"
-		"move.l	%3,-(sp);"
-		"move.l	%2,-(sp);"
-		"move.l	%1,a0;"
-		"jsr	(a0);"
-		"lea	16(sp),sp;"
-		"movem.l (sp)+,d3-d7/a3-a6;"
+		PUSH_SP("d3-d7/a3-a6", 36)
+		"move.l	%5,-(sp)\n\t"
+		"move.l	%4,-(sp)\n\t"
+		"move.l	%3,-(sp)\n\t"
+		"move.l	%2,-(sp)\n\t"
+		"move.l	%1,a0\n\t"
+		"jsr	(a0)\n\t"
+		"lea	16(sp),sp\n\t"
+		POP_SP("d3-d7/a3-a6", 36)
 		: "=r"(ret)						/* outputs */
 		: "g"(initfunc), "r"(k), "r"(a), "r"(arg), "g"(reason)	/* inputs  */
 		: __CLOBBER_RETURN("d0")
diff -x CVS -aurN freemint.orig/xaaes/src.km/draw_obj.c freemint/xaaes/src.km/draw_obj.c
--- freemint.orig/xaaes/src.km/draw_obj.c	2011-05-02 20:44:05.734375000 +0200
+++ freemint/xaaes/src.km/draw_obj.c	2011-05-06 07:32:52.906250000 +0200
@@ -340,12 +340,12 @@
 {
 	register long ret __asm__("d0");
 	__asm__ volatile (
-		"movem.l d3-d7/a3-a6,-(sp)\n\t"
+		PUSH_SP("d3-d7/a3-a6", 36)
 		"move.l %2,-(sp)\n\t"
 		"move.l %1,a0\n\t"
 		"jsr	(a0)\n\t"
 		"lea	4(sp),sp\n\t"
-		"movem.l (sp)+,d3-d7/a3-a6\n\t"
+		POP_SP("d3-d7/a3-a6", 36)
 			: "=r"(ret) 				/* outputs */
 			: "g"(f),"g"(p)
 			: __CLOBBER_RETURN("d0")
diff -x CVS -aurN freemint.orig/xaaes/src.km/mvdi.c freemint/xaaes/src.km/mvdi.c
--- freemint.orig/xaaes/src.km/mvdi.c	2010-12-14 18:07:01.171875000 +0100
+++ freemint/xaaes/src.km/mvdi.c	2011-05-05 22:45:36.687500000 +0200
@@ -76,7 +76,7 @@
 		"move.w		%1,-(sp)\n\t"		\
 		"move.w		#0x5f,-(sp)\n\t"	\
 		"trap		#14\n\t"		\
-		"addq.w		#4,sp\n\t"		\
+		"addq.l		#4,sp\n\t"		\
 		"move.w		d0,%0\n\t"		\
 		: "=d"(ret)
 		: "d"(mode)
@@ -96,7 +96,7 @@
 		"move.w		%1,-(sp)\n\t"		\
 		"move.w		#0x58,-(sp)\n\t"	\
 		"trap		#14\n\t"		\
-		"addq.w		#4,sp\n\t"		\
+		"addq.l		#4,sp\n\t"		\
 		"move.w		d0,%0\n\t"		\
 		: "=d"(ret)
 		: "d"(mode)
diff -x CVS -aurN freemint.orig/xaaes/src.km/nkcc-gc.S freemint/xaaes/src.km/nkcc-gc.S
--- freemint.orig/xaaes/src.km/nkcc-gc.S	2010-12-14 18:07:01.203125000 +0100
+++ freemint/xaaes/src.km/nkcc-gc.S	2011-05-16 00:04:24.894625000 +0200
@@ -94,32 +94,56 @@
 	btst	#NKFb_NUM,d0		| on numeric keypad?
 	beqs	search			| no ->
 
-	movew	#0x4a,d1		| yes: try all numeric keypad
+	moveql	#0x4a,d1		| yes: try all numeric keypad
+#ifdef __mcoldfire__
+	cmpb	a0@(d1:l),d0		|	scan codes first
+#else
 	cmpb	a0@(d1:w),d0		|	scan codes first
+#endif
 	beqs	found1			| it matches ->
 
-	movew	#0x4e,d1
+	moveql	#0x4e,d1
+#ifdef __mcoldfire__
+	cmpb	a0@(d1:l),d0
+#else
 	cmpb	a0@(d1:w),d0
+#endif
 	beqs	found1
 
-	movew	#0x63,d1		| block starts at 0x63
+	moveql	#0x63,d1		| block starts at 0x63
 
 numsearch:
+#ifdef __mcoldfire__
+	cmpb	a0@(d1:l),d0		| match?
+#else
 	cmpb	a0@(d1:w),d0		| match?
+#endif
 	beqs	found1			| yes ->
 
+#ifdef __mcoldfire__
+	addql	#1,d1			| next scan code
+#else
 	addqw	#1,d1			| next scan code
+#endif
 	cmpw	#0x73,d1		| block end at 0x72
 	bcss	numsearch		| continue search ->
 
 search:
-	movew	#1,d1			| start with first valid scan code
+	moveql	#1,d1			| start with first valid scan code
 
 mainsearch:
+#ifdef __mcoldfire__
+	cmpb	a0@(d1:l),d0		| match?
+#else
 	cmpb	a0@(d1:w),d0		| match?
+#endif
 	beqs	found1			| yes ->
 
+#ifdef __mcoldfire__
+	addql	#1,d1			| next scan code
+#else
 	addqb	#1,d1			| next scan code
+#endif
 	cmpb	#0x78,d1		| 0x78 = last valid scan code
 	bcss	mainsearch		| continue search ->
 
@@ -168,24 +192,43 @@
 
 _nkc_tos2n:
 	movel	sp@(4), d0		| Parameter via Stack!
+#ifdef __mcoldfire__
+	lea	sp@(-12),sp
+	movem.l	d2-d4,sp@		| store registers
+#else
 	movem.l	d2-d4,sp@- 		| store registers
+#endif
 
 |------------- separate TOS key code
 
 	movel	d0,d1			| TOS key code
 	swap	d1			| .W = scan code and flags
 	movew	d1,d2			| copy
+#ifdef __mcoldfire__
+	movel	#0xff,d3		| and-mask
+	andl	d3,d0			| .B = ASCII code
+	andl	d3,d1			| .B = scan code
+#else
 	movew	#0xff,d3		| and-mask
 	andw	d3,d0			| .B = ASCII code
 	andw	d3,d1			| .B = scan code
+#endif
 	beq	tos306			| scancode=zero (key code created
 						| by ASCII input of TOS 3.06)? ->
+#ifdef __mcoldfire__
+	andl	#0x1f00,d2		| .W = key flags (in high byte)
+#else
 	andw	#0x1f00,d2		| .W = key flags (in high byte)
+#endif
 
 |------------- decide which translation table to use
 
 	movew	d2,d3			| key flags
+#ifdef __mcoldfire__
+	andl	#NKFf_SHIFT,d3		| isolate bits for shift keys
+#else
 	andw	#NKFf_SHIFT,d3		| isolate bits for shift keys
+#endif
 	beqs	ktab11			| shift key pressed? no->
 
 	movel	pkey_shift,a0		| yes: use shift table
@@ -220,17 +263,37 @@
 
 	movew	d2,d1			| flags
 |	andw	#NKFf_ALT|NKFf_CTRL,d1	| Alternate or Control?
+#ifdef __mcoldfire__
+	andl	#0xc00,d1		| Alternate or Control?
+#else
 	andw	#0xc00,d1		| Alternate or Control?
+#endif
 	beqs	special 		| no ->
 
+#ifdef __mcoldfire__
+	orl	#NKFf_NUM,d0		| yes: set numeric keypad flag
+#else
 	orw	#NKFf_NUM,d0		| yes: set numeric keypad flag
+#endif
 |	and	#NKFf_CAPS|NKFf_SHIFT,d2	| mask off both flags
+#ifdef __mcoldfire__
+	andl	#0x1300,d2		| mask off both flags
+#else
 	andw	#0x1300,d2		| mask off both flags
+#endif
 
 special:
+#ifdef __mcoldfire__
+	orl	d2,d0			| combine with ASCII code
+#else
 	orw	d2,d0			| combine with ASCII code
+#endif
 |	orw	#NKFf_FUNC|NKFf_RESVD,d0	| set function and resvd
+#ifdef __mcoldfire__
+	orl	#0x1300,d0		| set function and resvd
+#else
 	orw	#0x1300,d0		| set function and resvd
+#endif
 	cmpb	#0x20,d0		| ASCII code in range?
 	bcc	exit2			| yes ->
 
@@ -243,9 +306,15 @@
 	cmpb	#0x78,d1		| scan code of Alt + number?
 	bcss	scan1			| no->
 
+#ifdef __mcoldfire__
+	subl	#0x76,d1		| yes: calculate REAL scan code
+	moveb	a0@(d1:l),d0		| fetch ASCII code
+	orl	#NKFf_ALT,d2		| set Alternate flag
+#else
 	subb	#0x76,d1		| yes: calculate REAL scan code
 	moveb	a0@(d1:w),d0		| fetch ASCII code
 	orw	#NKFf_ALT,d2		| set Alternate flag
+#endif
 	bra	cat_codes		| -> add flag byte and exit
 
 |------------- check if exception scan code from cursor keypad
@@ -260,7 +329,11 @@
 	cmpb	d1,d3			| scan code found?
 	bnes	search_scan		| no: continue search ->
 
+#ifdef __mcoldfire__
+	lsrl	#8,d3			| .B = NKC
+#else
 	lsrw	#8,d3			| .B = NKC
+#endif
 	moveql	#0,d0			| mark: key code found
 	bras	scan2			| ->
 
@@ -270,7 +343,11 @@
 |------------- check if rubbish ASCII code and erase it, if so
 
 scan2:
+#ifdef __mcoldfire__
+	moveb	a0@(d1:l),d4		| ASCII code from translation table
+#else
 	moveb	a0@(d1:w),d4		| ASCII code from translation table
+#endif
 	cmpb	#32,d0			| ASCII returned by TOS < 32?
 	bccs	scan3			| no -> can't be rubbish
 
@@ -290,7 +367,11 @@
 	beqs	scan4			| equal: normal key ->
 
 |	and	#!NKFf_ALT,d2		| no: clear Alternate flag
+#ifdef __mcoldfire__
+	andl	#0xF7FF,d2		| no: clear Alternate flag
+#else
 	andw	#0xF7FF,d2		| no: clear Alternate flag
+#endif
 
 |------------- check if ASCII code found yet, and set it, if not
 
@@ -327,7 +408,11 @@
 	bhis	scan7			| no ->
 
 numeric:
+#ifdef __mcoldfire__
+	orl	#NKFf_NUM,d2		| yes: set numeric bit
+#else
 	orw	#NKFf_NUM,d2		| yes: set numeric bit
+#endif
 
 |------------- check if "function key" and set bit accordingly
 
@@ -335,7 +420,11 @@
 	cmpb	#32,d0			| ASCII code less than 32?
 	bccs	scan8			| no ->
 
+#ifdef __mcoldfire__
+	orl	#NKFf_FUNC,d2		| yes: set function bit
+#else
 	orw	#NKFf_FUNC,d2		| yes: set function bit
+#endif
 
 |------------- check special case: Return or Enter key
 
@@ -356,11 +445,23 @@
 	cmpb	#0x5d,d1
 	bhis	scan9			| no ->
 
+#ifdef __mcoldfire__
+	subl	#0x54-0x3b,d1		| yes: scan code for unshifted key
+#else
 	subb	#0x54-0x3b,d1		| yes: scan code for unshifted key
+#endif
 	movew	d2,d3			| shift flags
+#ifdef __mcoldfire__
+	andl	#NKFf_SHIFT,d3		| any shift key flag set?
+#else
 	andw	#NKFf_SHIFT,d3		| any shift key flag set?
+#endif
 	bnes	scan9			| yes ->
+#ifdef __mcoldfire__
+	orl	#NKFf_SHIFT,d2		| no: set both flags
+#else
 	orw	#NKFf_SHIFT,d2		| no: set both flags
+#endif
 
 scan9:
 	cmpb	#0x3b,d1		| (unshifted) function key?
@@ -370,50 +471,92 @@
 	bhis	cat_codes		| no ->
 
 	moveb	d1,d0			| yes: calc NKC
+#ifdef __mcoldfire__
+	subl	#0x2b,d0
+#else
 	subb	#0x2b,d0
+#endif
 
 |------------- final flag handling| mix key code (low byte) and flag byte
 
 cat_codes:
 	movel	pkey_shift,a0		| ^shifted table
+#ifdef __mcoldfire__
+	moveb	a0@(d1:l),d3		| get shifted ASCII code
+	orl	d2,d0			| mix flags with key code
+	tst.w	d0
+#else
 	moveb	a0@(d1:w),d3		| get shifted ASCII code
 	orw	d2,d0			| mix flags with key code
+#endif
 	bmis	scan10			| result is "function key"? ->
 
+#ifdef __mcoldfire__
+	andl	#NKFf_CTRL+NKFf_ALT,d2	| Control or Alternate pressed?
+#else
 	andw	#NKFf_CTRL+NKFf_ALT,d2	| Control or Alternate pressed?
+#endif
 	bnes	scan11			| yes ->
 
 scan10:
 	movel	pkey_unshift,a0 	| ^unshifted table
+#ifdef __mcoldfire__
+	cmpb	a0@(d1:l),d3		| shifted ASCII = unshifted ASCII?
+#else
 	cmpb	a0@(d1:w),d3		| shifted ASCII = unshifted ASCII?
+#endif
 	beqs	scan12			| yes ->
 
 	bras	exit2			| no ->
 
 scan11:
+#ifdef __mcoldfire__
+	orl	#NKFf_FUNC,d0		| Alt/Ctrl + char: set function bit
+#else
 	orw	#NKFf_FUNC,d0		| Alt/Ctrl + char: set function bit
+#endif
 	movel	pkey_caps,a0		| ^CapsLock table
+#ifdef __mcoldfire__
+	cmpb	a0@(d1:l),d3		| shifted ASCII = CapsLocked ASCII?
+#else
 	cmpb	a0@(d1:w),d3		| shifted ASCII = CapsLocked ASCII?
+#endif
 	bnes	exit2			| no ->
 
 	moveb	d3,d0			| yes: use shifted ASCII code
 
 scan12:
+#ifdef __mcoldfire__
+	orl	#NKFf_RESVD,d0		| yes: nkc_cmp() has to check
+#else
 	orw	#NKFf_RESVD,d0		| yes: nkc_cmp() has to check
+#endif
 
 |------------- restore registers and exit
 
 exit2:
 	tstw	d0			| set CCR
+#ifdef __mcoldfire__
+	movem.l	sp@,d2-d4 		| restore registers
+	lea	sp@(12),sp
+#else
 	movem.l	sp@+,d2-d4 		| restore registers
+#endif
 	rts				| bye
 
 |------------- special handling for key codes created by TOS' 3.06 ASCII input
 
 tos306:
+#ifdef __mcoldfire__
+	andl	#NKFf_CAPS,d2		| isolate CapsLock flag
+	orl	d2,d0			| merge with ASCII code
+	movem.l	sp@,d2-d4 		| restore registers
+	lea	sp@(12),sp
+#else
 	andw	#NKFf_CAPS,d2		| isolate CapsLock flag
 	orw	d2,d0			| merge with ASCII code
 	movem.l	sp@+,d2-d4 		| restore registers
+#endif
 	rts				| bye
 
 |***************************************************************************
@@ -427,7 +570,11 @@
 
 	movew	d0,d1			| normalized key code
 |	and	#NKFf_FUNC|NKFf_ALT|NKFf_CTRL,d1| isolate flags
+#ifdef __mcoldfire__
+	andl	#0x8c00,d1		| isolate flags
+#else
 	andw	#0x8c00,d1		| isolate flags
+#endif
 	cmpw	#NKFf_FUNC,d1		| only function flag set?
 	bnes	ktab20			| no ->
 
@@ -443,10 +590,18 @@
 	beqs	mackey			| no ->
 
 |	or	#NKFf_ALT|NKFf_CTRL,d0	| yes: set Alternate + Control
+#ifdef __mcoldfire__
+	orl	#0xc00,d1		| yes: set Alternate + Control?
+#else
 	orw	#0xc00,d1		| yes: set Alternate + Control?
+#endif
 
 mackey:
+#ifdef __mcoldfire__
+	orl	#0xff,d0		| scan code always 0xff
+#else
 	orb	#0xff,d0		| scan code always 0xff
+#endif
 	swap	d0			| flags and scan code in upper word
 	moveb	d1,d0			| ASCII code
 	bra	exit3			| ->
@@ -455,7 +610,11 @@
 
 ktab20:
 	movew	d0,d1			| normalized key code
+#ifdef __mcoldfire__
+	andl	#NKFf_SHIFT,d1		| isolate bits for shift keys
+#else
 	andw	#NKFf_SHIFT,d1		| isolate bits for shift keys
+#endif
 	beqs	ktab21			| shift key pressed? no->
 
 	lea	n_to_scan_s,a1		| ^default translation table
@@ -489,7 +648,11 @@
 	lea	tolower,a0		| ^upper->lower case table
 	moveql	#0,d2			| clear for word operation
 	moveb	d0,d2			| ASCII code
+#ifdef __mcoldfire__
+	moveb	a0@(d2:l),d0		| get lowercased ASCII code
+#else
 	moveb	a0@(d2:w),d0		| get lowercased ASCII code
+#endif
 	movel	d1,a0			| restore a0
 	bsr	nk_findscan		| try to find scan code again
 	bnes	found2			| found ->
@@ -500,7 +663,11 @@
 notfound:
 	moveql	#0,d1			| not found: clear for word op.
 	moveb	d0,d1			| unchanged ASCII code
+#ifdef __mcoldfire__
+	andl	#0x1f00,d0		| keep shift flags only
+#else
 	andw	#0x1f00,d0		| keep shift flags only
+#endif
 	swap	d0			| -> high word (scan code = 0)
 	movew	d1,d0			| low word: ASCII code
 	bra	exit3			| ->
@@ -511,14 +678,22 @@
 	btst	#NKFb_FUNC,d0		| function key?
 	bnes	func			| yes ->
 
+#ifdef __mcoldfire__
+	andl	#0xffff10ff,d0		| clear all flags except CapsLock
+#else
 	andw	#0x10ff,d0		| clear all flags except CapsLock
+#endif
 	bras	notfound		| ->
 
 func:
 	moveql	#0,d1			| clear for word operation
 	moveb	d0,d1			| ASCII code (0...0x1f)
 	movew	d1,d2			| copy
+#ifdef __mcoldfire__
+	moveb	a1@(d1:l),d1		| get scan code
+#else
 	moveb	a1@(d1:w),d1		| get scan code
+#endif
 	bnes	getascii		| valid? ->
 
 	moveq	#0,d0			| invalid key code!! return 0
@@ -526,8 +701,13 @@
 
 getascii:
 	lea	n_to_scan_u,a1		| ^unshifted translation table
+#ifdef __mcoldfire__
+	moveb	a1@(d2:l),d2		| get scan code from unshifted tab.
+	moveb	a0@(d2:l),d0		| get ASCII from system's table
+#else
 	moveb	a1@(d2:w),d2		| get scan code from unshifted tab.
 	moveb	a0@(d2:w),d0		| get ASCII from system's table
+#endif
 
 | register contents:
 |
@@ -538,7 +718,11 @@
 
 found2:
 	movew	d0,d2			| flags and ASCII code
+#ifdef __mcoldfire__
+	andl	#0x1f00,d0		| isolate shift flags
+#else
 	andw	#0x1f00,d0		| isolate shift flags
+#endif
 	moveb	d1,d0			| merge with scan code
 	swap	d0			| -> high byte
 	clrw	d0			| erase low word
@@ -582,12 +766,20 @@
 	cmpb	d0,d1			| ASCII code found?
 	bnes	ascloop 		| no -> continue search
 
+#ifdef __mcoldfire__
+	lsrl	#8,d1			| yes: get translated code
+#else
 	lsrw	#8,d1			| yes: get translated code
+#endif
 	moveb	d1,d0			| use it
 	bras	exit3			| ->
 
 noctrlasc:
+#ifdef __mcoldfire__
+	andl	#0x1f,d0		| mask off upper 3 bits
+#else
 	andb	#0x1f,d0		| mask off upper 3 bits
+#endif
 	bras	exit3			| ->
 
 |------------- handling for Alternate key flag
@@ -636,7 +828,11 @@
 _nkc_toupper:
 	movel	sp@(4),d1		| Parameter via Stack!
 	lea	toupper,a0		| ^upper case translation table
+#ifdef __mcoldfire__
+	andl	#0xff,d1		| high byte = 0 for word operation
+#else
 	andw	#0xff,d1		| high byte = 0 for word operation
+#endif
 	moveb	a0@(d1:l),d0		| convert
 	rts				| bye
 
@@ -649,7 +845,11 @@
 _nkc_tolower:
 	movel	sp@(4),d1		| Parameter via Stack!
 	lea	tolower,a0		| ^lower case translation table
+#ifdef __mcoldfire__
+	andl	#0xff,d1		| high byte = 0 for word operation
+#else
 	andw	#0xff,d1		| high byte = 0 for word operation
+#endif
 	moveb	a0@(d1:l),d0		| convert
 	rts				| bye
 
diff -x CVS -aurN freemint.orig/xaaes/src.km/version.h freemint/xaaes/src.km/version.h
--- freemint.orig/xaaes/src.km/version.h	2011-05-10 19:49:35.546875000 +0200
+++ freemint/xaaes/src.km/version.h	2011-05-11 21:24:59.781250000 +0200
@@ -73,7 +73,7 @@
 #endif
 
 #ifdef __mcoldfire__
- #define _CPU	"coldfire"
+ #define _CPU	"ColdFire"
 #else
  #ifdef mc68060
   #ifdef mc68020
diff -x CVS -aurN freemint.orig/xaaes/src.km/xa_user_things.S freemint/xaaes/src.km/xa_user_things.S
--- freemint.orig/xaaes/src.km/xa_user_things.S	2005-01-13 15:53:53.000000000 +0100
+++ freemint/xaaes/src.km/xa_user_things.S	2011-05-16 00:24:39.925875000 +0200
@@ -47,7 +47,7 @@
 	move.l	d0,a0
 	pea	_parmblk(pc)
 	jsr	(a0)
-	addq.w	#4,sp
+	addq.l	#4,sp
 nofunc:
 	lea	_retcode(pc),a0
 	move.l	d0,(a0)
@@ -64,7 +64,12 @@
 	.long	callout_ret		- _xa_callout_user
 	
 callout_user:
+#ifdef __mcoldfire__
+	lea	-60(sp),sp
+	movem.l	d0-d7/a0-a6,(sp)
+#else
 	movem.l	d0-d7/a0-a6,-(sp)
+#endif
 	lea	callout_func(pc),a0
 	move.l	(a0)+,d0
 	beq.s	callout_exit
@@ -73,10 +78,19 @@
 	beq.s	callout_noparms
 	adda.l	d1,a0
 	adda.l	d1,a0
+#ifdef __mcoldfire__
+	subq.l	#1,d1
+#else
 	subq.w	#1,d1
+#endif
 callout_gparms:
 	move.w	-(a0),-(sp)
+#ifdef __mcoldfire__
+	subq.l	#1,d1
+	bpl.s	callout_gparms
+#else
 	dbra	d1,callout_gparms
+#endif
 callout_noparms:
 	move.l	d0,a0
 	jsr	(a0)
@@ -87,7 +101,12 @@
 	adda.l	d1,sp
 	adda.l	d1,sp
 callout_exit:
+#ifdef __mcoldfire__
+	movem.l	(sp),d0-d7/a0-a6
+	lea	60(sp),sp
+#else
 	movem.l	(sp)+,d0-d7/a0-a6
+#endif
 	rts
 
 callout_ret:	dc.l 0