1/* 2Copyright (c) 1990 The Regents of the University of California. 3All rights reserved. 4 5Redistribution and use in source and binary forms are permitted 6provided that the above copyright notice and this paragraph are 7duplicated in all such forms and that any documentation, 8and/or other materials related to such 9distribution and use acknowledge that the software was developed 10by the University of California, Berkeley. The name of the 11University may not be used to endorse or promote products derived 12from this software without specific prior written permission. 13THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 .title "H8/500 DIVIDE" 18!! 2 byte integer Divide code for the H8/500 19!! 20!! Steve Chamberlain 21!! sac@cygnus.com 22!! 23!! 24 25!! args in r1 and r4, result in r0/r1 26 27#if __CODE__==32 28#define RET prts 29#else 30#define RET rts 31#endif 32 .global __divmodhi4 33 34 35__divmodhi4: 36 clr.w r0 37 tst.w r1 ! neg arg1 38 bpl PU 39 40 41 neg.w r1 42NU: tst.w r4 43 bmi NN 44 45NP: divxu.w r4,r0 46 neg.w r0 47 neg.w r1 48 RET 49 50NN: neg.w r4 51 divxu.w r4,r0 52 neg.w r0 ! get rem sign right 53 RET 54 55 56PU: 57 tst.w r4 58 bpl PP 59 60 61PN: neg.w r4 62 divxu.w r4,r0 63 neg.w r1 64 RET 65 66PP: divxu.w r4,r0 ! rem in r0, q in r1 67 RET 68 69 70 71