mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-12-29 01:30:22 +00:00
Modulo shift/rotate counts
This commit is contained in:
parent
4c4ec7c985
commit
85295c5515
@ -158,6 +158,8 @@ LISP 1.5 Manual: https://archive.org/details/bitsavers_mitrlelisprammersManual2e
|
||||
|
||||
LISP 1.5 Primer: https://www.softwarepreservation.org/projects/LISP/book/Weismann_LISP1.5_Primer_1967.pdf
|
||||
|
||||
P-LISP Manual (newer than LISP 1.5): https://archive.org/details/gLISP/gnosisLISPManual
|
||||
|
||||
Apple Numerics Manual (SANE): https://vintageapple.org/inside_o/pdf/Apple_Numerics_Manual_Second_Edition_1988.pdf
|
||||
|
||||
Video showing DRAWL in action: https://youtu.be/wBMivg6xfSg
|
||||
|
@ -710,28 +710,38 @@ def natv_shift(symptr, expr)
|
||||
//
|
||||
// Shift right
|
||||
//
|
||||
while shift < 0
|
||||
bitval[0] = bitval[0] >> 1
|
||||
if bitval[1] & 1
|
||||
bitval[0] = bitval[0] | $8000
|
||||
else
|
||||
bitval[0] = bitval[0] & $7FFF
|
||||
fin
|
||||
bitval[1] = bitval[1] >> 1
|
||||
shift++
|
||||
loop
|
||||
if shift < -31
|
||||
bitval[1] = bitval[1] < 0 ?? $FFFF :: 0
|
||||
bitval[0] = bitval[1]
|
||||
else
|
||||
while shift < 0
|
||||
bitval[0] = bitval[0] >> 1
|
||||
if bitval[1] & 1
|
||||
bitval[0] = bitval[0] | $8000
|
||||
else
|
||||
bitval[0] = bitval[0] & $7FFF
|
||||
fin
|
||||
bitval[1] = bitval[1] >> 1
|
||||
shift++
|
||||
loop
|
||||
fin
|
||||
else
|
||||
//
|
||||
// Shift left
|
||||
//
|
||||
while shift > 0
|
||||
bitval[1] = bitval[1] << 1
|
||||
if bitval[0] & $8000
|
||||
bitval[1] = bitval[1] | 1
|
||||
fin
|
||||
bitval[0] = bitval[0] << 1
|
||||
shift--
|
||||
loop
|
||||
if shift > 31
|
||||
bitval[0] = 0
|
||||
bitval[1] = 0
|
||||
else
|
||||
while shift > 0
|
||||
bitval[1] = bitval[1] << 1
|
||||
if bitval[0] & $8000
|
||||
bitval[1] = bitval[1] | 1
|
||||
fin
|
||||
bitval[0] = bitval[0] << 1
|
||||
shift--
|
||||
loop
|
||||
fin
|
||||
fin
|
||||
return new_int(bitval[0], bitval[1])
|
||||
end
|
||||
@ -746,6 +756,7 @@ def natv_rotate(symptr, expr)
|
||||
symptr = eval_int(expr=>cdr)
|
||||
rotate = symptr=>intval[0]
|
||||
if rotate < 0
|
||||
rotate = rotate | $FFFFFFE0
|
||||
while rotate < 0
|
||||
wrap = bitval[0] & 1 ?? $8000 :: 0
|
||||
bitval[0] = bitval[0] >> 1
|
||||
@ -758,6 +769,7 @@ def natv_rotate(symptr, expr)
|
||||
rotate++
|
||||
loop
|
||||
else
|
||||
rotate = rotate & $0000001F
|
||||
while rotate > 0
|
||||
wrap = bitval[1] & $8000 ?? 1 :: 0
|
||||
bitval[1] = bitval[1] << 1
|
||||
|
Loading…
Reference in New Issue
Block a user