As reported by Amadeusz Sławiński using a real Mac, if anything is divided by zero then we should return zero:
0 > 2 0 / ok 1 > u. 0 ok
This resolves a bug in BootX which (un)intentionally divides by zero during boot.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/ppc.fs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/openbios-devel/arch/ppc/ppc.fs b/openbios-devel/arch/ppc/ppc.fs index 6995ba9..e07765b 100644 --- a/openbios-devel/arch/ppc/ppc.fs +++ b/openbios-devel/arch/ppc/ppc.fs @@ -55,3 +55,23 @@
\ Set by BootX when booting Mac OS X defer spin + +\ BootX has a bug whereby it divides by zero when booting from any device +\ other than the network (see openbios list archive for details). The +\ behaviour on real hardware is for the trap to "catch" the exception and +\ then continue. +\ +\ Since OpenBIOS PPC can't trap into Forth, we emulate this behaviour by +\ checking for divide by zero and returning the same result as real hardware +\ which is a single zero e.g. +\ +\ 0 > 2 0 / ok +\ 1 > u. 0 ok + +:noname + dup 0= if + 3drop 0 0 0 + else + mu/mod + then +; to (mu/mod)