OpenCores
URL https://opencores.org/ocsvn/forwardcom/forwardcom/trunk

Subversion Repositories forwardcom

[/] [forwardcom/] [libraries/] [divide_int.as] - Blame information for rev 166

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 73 Agner
/****************************  divide_int.as ********************************
2
* Author:        Agner Fog
3
* date created:  2021-05-26
4
* Last modified: 2021-08-03
5
* Version:       1.11
6
* Project:       ForwardCom library libc.li
7
* Description:   divide_int: divide two 32-bit signed integers
8
* This function is for compatability with libc_light.li.
9
* It returns the quotient and the remainder of r0 / r1
10
*
11
* Copyright 2021 GNU General Public License http://www.gnu.org/licenses
12
*****************************************************************************/
13
 
14
 
15
code section execute
16
 
17
_divide_int function public reguse=3,0
18
  // divide two 32 bit signed integers. return quotient and remainder
19
  // input r0: dividend
20
  // input r1: divisor
21
  // output r0: r0 / r1
22
  // output r1: r0 % r1
23
 
24
  if (int32 r1 != 0) {
25
      int32  r2 = r0 / r1
26
      int32  r1 = r0 % r1
27
      int32  r0 = r2
28
      return
29
  }
30
  // return INT_MIN if error
31
  int32 r0 = 0x80000000
32
  int32 r1 = 0
33
  return
34
 
35
code end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.