Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* memset.S */ |
| 2 | |
| 3 | #include <asm/linkage.h> |
| 4 | |
| 5 | #if defined(__H8300H__) |
| 6 | .h8300h |
| 7 | #endif |
| 8 | #if defined(__H8300S__) |
| 9 | .h8300s |
| 10 | #endif |
| 11 | .text |
| 12 | |
Geert Uytterhoeven | db5ede6 | 2013-05-06 21:32:46 +0200 | [diff] [blame^] | 13 | .global _memset |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | ;;void *memset(*ptr, int c, size_t count) |
| 16 | ;; ptr = er0 |
| 17 | ;; c = er1(r1l) |
| 18 | ;; count = er2 |
Geert Uytterhoeven | db5ede6 | 2013-05-06 21:32:46 +0200 | [diff] [blame^] | 19 | _memset: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | btst #0,r0l |
| 21 | beq 2f |
| 22 | |
| 23 | ;; odd address |
| 24 | 1: |
| 25 | mov.b r1l,@er0 |
| 26 | adds #1,er0 |
| 27 | dec.l #1,er2 |
| 28 | beq 6f |
| 29 | |
| 30 | ;; even address |
| 31 | 2: |
| 32 | mov.l er2,er3 |
| 33 | cmp.l #4,er2 |
| 34 | blo 4f |
| 35 | ;; count>=4 -> count/4 |
| 36 | #if defined(__H8300H__) |
| 37 | shlr.l er2 |
| 38 | shlr.l er2 |
| 39 | #endif |
| 40 | #if defined(__H8300S__) |
| 41 | shlr.l #2,er2 |
| 42 | #endif |
| 43 | ;; byte -> long |
| 44 | mov.b r1l,r1h |
| 45 | mov.w r1,e1 |
| 46 | 3: |
| 47 | mov.l er1,@er0 |
| 48 | adds #4,er0 |
| 49 | dec.l #1,er2 |
| 50 | bne 3b |
| 51 | 4: |
| 52 | ;; count % 4 |
| 53 | and.b #3,r3l |
| 54 | beq 6f |
| 55 | 5: |
| 56 | mov.b r1l,@er0 |
| 57 | adds #1,er0 |
| 58 | dec.b r3l |
| 59 | bne 5b |
| 60 | 6: |
| 61 | rts |