strange corner cases:
(1) zero top 32 bits for 32-bit unsigned ops; 32-bit value can be accidentally(?) sign-extended by the compiler/assembler. (2) fix return value for mod's that cause traps
This commit is contained in:
parent
9e15c98955
commit
3f45f31f15
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: divrem.m4,v 1.1 1995/02/10 17:50:20 cgd Exp $ */
|
||||
/* $NetBSD: divrem.m4,v 1.2 1995/02/25 03:09:32 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
|
||||
|
@ -84,7 +84,15 @@ LnegB:
|
|||
/* B is definitely negative, no matter how we got here. */
|
||||
subq zero, B, B
|
||||
Ldoit:
|
||||
')
|
||||
', `
|
||||
ifelse(WORDSIZE, `32', `
|
||||
/*
|
||||
* Clear the top 32 bits of each operand, as the compiler may
|
||||
* have sign extended them, if the 31st bit was set.
|
||||
*/
|
||||
zap A, 0xf0, A
|
||||
zap B, 0xf0, B
|
||||
')' )
|
||||
|
||||
/* kill the special cases. */
|
||||
beq B, Ldotrap /* division by zero! XXX */
|
||||
|
@ -164,6 +172,9 @@ ifelse(S, `true',
|
|||
Ldotrap:
|
||||
CONST(-2, a0) /* This is the signal to SIGFPE! */
|
||||
call_pal PAL_gentrap
|
||||
ifelse(OP, `div',
|
||||
`', ` mov zero, A /* so that zero will be returned */
|
||||
')
|
||||
br zero, Lret_result
|
||||
|
||||
END(NAME)
|
||||
|
|
Loading…
Reference in New Issue