1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-01 06:32:07 +00:00

Modulo shift/rotate counts

This commit is contained in:
David Schmenk 2024-07-20 07:51:56 -07:00
parent 4c4ec7c985
commit 85295c5515
2 changed files with 32 additions and 18 deletions

View File

@ -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

View File

@ -710,6 +710,10 @@ def natv_shift(symptr, expr)
//
// Shift right
//
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
@ -720,10 +724,15 @@ def natv_shift(symptr, expr)
bitval[1] = bitval[1] >> 1
shift++
loop
fin
else
//
// Shift left
//
if shift > 31
bitval[0] = 0
bitval[1] = 0
else
while shift > 0
bitval[1] = bitval[1] << 1
if bitval[0] & $8000
@ -733,6 +742,7 @@ def natv_shift(symptr, expr)
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