File: mips.h

package info (click to toggle)
gcl 2.6.7%2Bdfsga-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 84,796 kB
  • sloc: ansic: 452,686; lisp: 156,133; asm: 111,405; sh: 29,299; cpp: 18,599; perl: 5,602; makefile: 5,201; tcl: 3,181; sed: 469; yacc: 378; lex: 174; fortran: 48; awk: 30; csh: 23
file content (37 lines) | stat: -rwxr-xr-x 803 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

/* amazingly the only instructions which the mips seems to have for overflow
 is add and sub which signal:
 	       Integer overflow			SIGTRAP	    BRK_OVERFLOW
 on overflow.   Of course that is much too expensive.
 Their div instruction does only  32 by 32 bit divide.
*/

	       

#ifdef __GNUC__
/* so have assembler macros */
/*    mulul is a macro:
    f = mulul(a,b,h) <--> h:f  == a*b
*/

#define mulul(x,y,hiremainder) \
({ulong __x =(x),__y=(y),__res; \
  asm volatile("multu %2,%3\n\tmflo %0\n\tmfhi %1" \
     :"=r" (__res),"=r" (hiremainder) \
     :"r" (__x),"r"(__y));  \
   __res;})


  /* add_carry: add X and Y  adding 1 to H if there was overflow
     H is presumed to be small enough not to overflow 
     */
     
#else  /* not gcc */


#endif
     


  
#define BASE_COUNTER -1