1 .title "H8/500 DIVIDE" 2!! 2 byte integer Divide code for the H8/500 3!! 4!! Steve Chamberlain 5!! sac@cygnus.com 6!! 7!! 8 9!! args in r1 and r4, result in r0/r1 10 11#if __CODE__==32 12#define RET prts 13#else 14#define RET rts 15#endif 16 .global __divmodhi4 17 18 19__divmodhi4: 20 clr.w r0 21 tst.w r1 ! neg arg1 22 bpl PU 23 24 25 neg.w r1 26NU: tst.w r4 27 bmi NN 28 29NP: divxu.w r4,r0 30 neg.w r0 31 neg.w r1 32 RET 33 34NN: neg.w r4 35 divxu.w r4,r0 36 neg.w r0 ! get rem sign right 37 RET 38 39 40PU: 41 tst.w r4 42 bpl PP 43 44 45PN: neg.w r4 46 divxu.w r4,r0 47 neg.w r1 48 RET 49 50PP: divxu.w r4,r0 ! rem in r0, q in r1 51 RET 52 53 54 55