User Tools

Site Tools


en:pfw:dlshift_drshift

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:pfw:dlshift_drshift [2024-04-04 23:20] – [Possibly a problem] alberten:pfw:dlshift_drshift [2024-04-09 14:41] (current) – [Test results (noForth t)] albert
Line 1: Line 1:
-===== Shifting doublesDLSHIFT and DRSHIFT =====+===== Shifting doublesDLSHIFT and DRSHIFT =====
 an.02apr2024 an.02apr2024
  
Line 11: Line 11:
 decimal  decimal 
 : DLSHIFT ( lo hi n -- lo' hi' )    \ n in [0,32*2] : DLSHIFT ( lo hi n -- lo' hi' )    \ n in [0,32*2]
-    tuck lshift >r              \ hi' +    tuck lshift >r          \ hi' 
-    2dup 32 - negate rshift >r  upper lo to lower hi +    2dup 32 -  
-    2dup 32 - lshift >r         lower lo to upper hi +    2dup   lshift >r        lower lo to upper hi 
-    lshift                      \ lo' +    negate rshift >r        upper lo to lower hi 
-    2r> r> or or   ;            build hi' +    lshift                  \ lo' 
 +    2r> r> or or   ;        compose hi' 
 +    
 : DRSHIFT ( lo hi n -- lo' hi' )    \ n in [0,32*2] : DRSHIFT ( lo hi n -- lo' hi' )    \ n in [0,32*2]
-    tuck 2dup rshift >r         \ hi' +    tuck 2dup rshift >r     \ hi' 
-    2dup 32 - negate lshift >r  lower hi to upper lo +    32 - 
-    32 - rshift >r              upper hi to lower lo +    2dup   rshift >r        upper hi to lower lo 
-    rshift 2r> or or            build lo' +    negate lshift >r        lower hi to upper lo 
-    r> ;                        \ hi'+    rshift 2r> or or        compose lo' 
 +    r> ;                    \ hi'
 </code> </code>
 ===== Possibly a problem ===== ===== Possibly a problem =====
Line 38: Line 40:
 : (TEST) ( ud ud -- ) 2over 2over du.hex du.hex : (TEST) ( ud ud -- ) 2over 2over du.hex du.hex
     cr ." #shifts dlshift--------- drshift---------"     cr ." #shifts dlshift--------- drshift---------"
-    32 2* +   -2+    32 2* +   -2
     do cr i 3 and 0= if cr then i 7 .r space     do cr i 3 and 0= if cr then i 7 .r space
         2over 2over i dlshift du.hex i drshift du.hex         2over 2over i dlshift du.hex i drshift du.hex
Line 48: Line 50:
 ===== Test results (noForth t) ===== ===== Test results (noForth t) =====
 <code> <code>
-:)test1 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF+@)test1 FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
 #shifts dlshift--------- drshift--------- #shifts dlshift--------- drshift---------
      -2 0000000000000000 0000000000000000      -2 0000000000000000 0000000000000000
Line 134: Line 136:
  
      40 0000000000000000 0000000000000000      40 0000000000000000 0000000000000000
-     41 0000000000000000 0000000000000000 +     41 0000000000000000 0000000000000000 OK.0
-     42 0000000000000000 0000000000000000  OK.0+
 </code> </code>
 <code> <code>
- +@)test2 0000000000000001 8000000000000000
-:)test2 0000000000000001 8000000000000000+
 #shifts dlshift--------- drshift--------- #shifts dlshift--------- drshift---------
      -2 0000000000000000 0000000000000000      -2 0000000000000000 0000000000000000
Line 225: Line 225:
  
      40 0000000000000000 0000000000000000      40 0000000000000000 0000000000000000
-     41 0000000000000000 0000000000000000 +     41 0000000000000000 0000000000000000  OK.0
-     42 0000000000000000 0000000000000000  OK.0+
 </code> </code>
 ===== Contributions ===== ===== Contributions =====
en/pfw/dlshift_drshift.1712265646.txt.gz · Last modified: 2024-04-04 23:20 by albert