From c076939fe25095df4ee854d999240da718987dad Mon Sep 17 00:00:00 2001 From: Jesse McDonald Date: Fri, 6 Nov 2020 20:29:48 -0600 Subject: [PATCH] fix for incorrect double-cell shift by 32 or more bits --- jumpforth.S | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/jumpforth.S b/jumpforth.S index ce387b0..a7c4bc9 100644 --- a/jumpforth.S +++ b/jumpforth.S @@ -630,30 +630,67 @@ defcode DUTWODIV,"DU2/" /* ( x1 u -- x2 ) Shift left by u bits */ defcode LSHIFT pop %ecx + cmp $32,%ecx + jae 1f shll %cl,(%esp) NEXT +1: movl $0,(%esp) + NEXT /* ( u1 u -- u2 ) Logical (unsigned) shift right by u bits */ defcode RSHIFT pop %ecx + cmp $32,%ecx + jae 1f shrl %cl,(%esp) NEXT +1: movl $0,(%esp) + NEXT /* ( xd1 u -- xd2 ) Shift left by u bits */ defcode DLSHIFT pop %ecx + cmp $32,%ecx + jae 1f movl 4(%esp),%eax shldl %cl,%eax,(%esp) shll %cl,4(%esp) NEXT +1: pop %ebx + pop %eax + xor %ebx,%ebx + cmp $64,%ecx + jae 2f + shl %cl,%eax + push %ebx + push %eax + NEXT +2: push %ebx + push %ebx + NEXT /* ( ud1 u -- ud2 ) Logical (unsigned) shift right by u bits */ defcode DRSHIFT pop %ecx + cmp $32,%ecx + jae 1f movl (%esp),%eax shrdl %cl,%eax,4(%esp) shrl %cl,(%esp) NEXT +1: pop %ebx + pop %eax + xor %eax,%eax + cmp $64,%ecx + jae 2f + shr %cl,%ebx + push %ebx + push %eax + NEXT +2: push %eax + push %eax + NEXT + .macro defzcmp label,ncc,name="\label",flags=0 defcode \label,"\name",0,\flags