Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
565 bytes
|
Rev | Line | |
---|
[444] | 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 |
---|
| 26 | NU: tst.w r4 |
---|
| 27 | bmi NN |
---|
| 28 | |
---|
| 29 | NP: divxu.w r4,r0 |
---|
| 30 | neg.w r0 |
---|
| 31 | neg.w r1 |
---|
| 32 | RET |
---|
| 33 | |
---|
| 34 | NN: neg.w r4 |
---|
| 35 | divxu.w r4,r0 |
---|
| 36 | neg.w r0 ! get rem sign right |
---|
| 37 | RET |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | PU: |
---|
| 41 | tst.w r4 |
---|
| 42 | bpl PP |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | PN: neg.w r4 |
---|
| 46 | divxu.w r4,r0 |
---|
| 47 | neg.w r1 |
---|
| 48 | RET |
---|
| 49 | |
---|
| 50 | PP: divxu.w r4,r0 ! rem in r0, q in r1 |
---|
| 51 | RET |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | |
---|
Note: See
TracBrowser
for help on using the repository browser.