Skip to content

Instantly share code, notes, and snippets.

@erikcorry
Created October 10, 2026 09:53
Show Gist options
  • Select an option

  • Save erikcorry/e30152f9ecbdacdab84792186d60acff to your computer and use it in GitHub Desktop.

Select an option

Save erikcorry/e30152f9ecbdacdab84792186d60acff to your computer and use it in GitHub Desktop.
16 bit unsigned divmod for Fructus disassembly
00000000 <divmod>:
0: 90 07 push r7
2: 53 0f or r7, r1, #0
4: 28 51 mov r1, #10
6: a7 cc 1c br eq, r7, r1, 25 <divmod+0x25>
9: 33 39 clz r1, r7
b: 67 3d shl r5, r7, r1
d: c3 2d recip r5, r5, #0
f: 70 0d lsr r5, r5, #1
11: 54 7d or r5, r5, #0x8000
13: b6 2d mulhu r5, r5, r0
15: 40 79 rsb r1, r1, #15
17: 77 2d lsr r5, r5, r1
19: 37 b9 mul r1, r7, r5
1b: 46 09 rsb r1, r1, r0
1d: a7 cb 16 br ls, r7, r1, 36 <divmod+0x36>
20: 53 28 or r0, r5, #0
22: 98 07 pop r7
24: ab ret
25: 8d cd cc mov r5, #-13107
28: b7 85 mulhu r5, r0, r5
2a: 70 1d lsr r5, r5, #3
2c: 31 a9 02 mul r1, r5, #10
2f: 46 09 rsb r1, r1, r0
31: 53 28 or r0, r5, #0
33: 98 07 pop r7
35: ab ret
36: 38 0d add r5, r5, #1
38: 47 39 rsb r1, r7, r1
3a: a3 e4 jmpr 20 <divmod+0x20>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment