1/* 2 * Copyright (C) 2016-2017 Free Software Foundation, Inc. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation, version 2. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 */ 13 14 .globl __udivdi3 15__udivdi3: 16 mv a2, a1 17 mv a1, a0 18 li a0, -1 19 beqz a2, .L5 20 li a3, 1 21 bgeu a2, a1, .L2 22.L1: 23 blez a2, .L2 24 slli a2, a2, 1 25 slli a3, a3, 1 26 bgtu a1, a2, .L1 27.L2: 28 li a0, 0 29.L3: 30 bltu a1, a2, .L4 31 sub a1, a1, a2 32 or a0, a0, a3 33.L4: 34 srli a3, a3, 1 35 srli a2, a2, 1 36 bnez a3, .L3 37.L5: 38 ret 39