Port-m68k archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Help with integer division overflow issue



thorpej@ wrote:

> Ok, can you try this one?
 :
> sun3-160$ ./a.out
> val = -2147483648 (0x80000000)
> ccr = 0x02
> sun3-160$ 

Here (test-ccr binary is on NFS and all machines use the same one):

sun 3/60 (MC68020):
---
# uname -a
NetBSD  10.0_RC2 NetBSD 10.0_RC2 (GENERIC) #0: Mon Jan  1 14:04:52 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/sun3/compile/GENERIC sun3
# sysctl hw.model
hw.model = sun3 60
# cat test-ccr.c
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>

int divisor = -1;

int
main(int argc, char *argv[])
{
int val = INT_MIN;
int ccr = 0;

__asm __volatile("divsl divisor,%1" : "=r" (val) : "0" (val));
__asm __volatile("move %%ccr,%0" : "=r" (ccr));

printf("val = %d (0x%08x)\n", val, val);
printf("ccr = 0x%02x\n", ccr);

return 0;
}

# cc -o test-ccr test-ccr.c
# ./test-ccr
val = -2147483648 (0x80000000)
ccr = 0x80000008
# 
---

X68030 (MC68030):
---
roppa-% uname -a
NetBSD roppa 10.0_BETA NetBSD 10.0_BETA (GENERIC) #0: Sun Oct  8 15:24:41 UTC 2023  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/x68k/compile/GENERIC x68k
roppa-% sysctl hw.model
hw.model = X68030 (m68030 CPU/MMU, m68882 FPU, 25MHz clock)
roppa-% ./test-ccr
val = -2147483648 (0x80000000)
ccr = 0x80000008
roppa-% 
---

Milan (XC68040):
---
milan-% uname -a
NetBSD milan 10.0_RC2 NetBSD 10.0_RC2 (MILAN-PCIIDE) #0: Mon Jan  1 14:04:52 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/atari/compile/MILAN-PCIIDE atari
milan-% sysctl hw.model
hw.model = Atari Milan (MC68040 CPU/MMU/FPU)
milan-% ./test-ccr
val = -2147483648 (0x80000000)
ccr = 0x80000008
milan-% 
---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index