j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/bootstrap/bootstrap.fs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/openbios-devel/forth/bootstrap/bootstrap.fs b/openbios-devel/forth/bootstrap/bootstrap.fs index 6878449..ded2e90 100644 --- a/openbios-devel/forth/bootstrap/bootstrap.fs +++ b/openbios-devel/forth/bootstrap/bootstrap.fs @@ -445,10 +445,15 @@ variable leaves 0 leaves ! \ 7.3.2.3 double number arithmetic \
+defer (mu/mod) + : s>d dup 0 < ; : dnegate 0 0 2swap d- ; : dabs dup 0 < if dnegate then ; -: um/mod mu/mod drop ; +: um/mod (mu/mod) drop ; + +\ default divide implementation +['] mu/mod ['] (mu/mod) (to)
\ symmetric division : sm/rem ( d n -- rem quot )
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)