@@ -1677,7 +1677,8 @@ Each register plays the same role as in x86, so for example
16771677
16781678@defstruct*[Sal ([dst register?] [i (integer-in 0 63 )])]{
16791679 Shift @racket[dst] to the left @racket[i] bits and put result in @racket[dst].
1680- The leftmost bits are discarded. Updates the conditional flags.
1680+ The most-significant (leftmost) bits are discarded. Updates the conditional
1681+ flags.
16811682
16821683 @#reader scribble/comment-reader
16831684 (ex
@@ -1693,8 +1694,9 @@ Each register plays the same role as in x86, so for example
16931694
16941695@defstruct*[Sar ([dst register?] [i (integer-in 0 63 )])]{
16951696 Shift @racket[dst] to the right @racket[i] bits and put result in @racket[dst].
1696- The rightmost bits are discarded. The added leftmost bits are filled with the
1697- sign bit of the original. Updates the conditional flags.
1697+ For each shift count, the least-significant (rightmost) bit is shifted into
1698+ the carry flag. The new most-significant (leftmost) bits are filled with the
1699+ sign bit of the original @racket[dst] value. Updates the conditional flags.
16981700
16991701 @#reader scribble/comment-reader
17001702 (ex
@@ -1713,6 +1715,52 @@ Each register plays the same role as in x86, so for example
17131715 (Mov 'rax #b100001101 ) ; #b100001101 = 269
17141716 (Sar 'rax 6 )
17151717 (Ret))) ; #b100 = 4
1718+
1719+ (asm-interp
1720+ (prog
1721+ (Global 'entry )
1722+ (Label 'entry )
1723+ (Mov 'rax #b1000000000000000000000000000000000000000000000000000000000000000 ) ; 1 in MSB
1724+ (Sar 'rax 6 )
1725+ (Ret))) ; #b1111111000000000000000000000000000000000000000000000000000000000
1726+ )
1727+ }
1728+
1729+ @defstruct*[Shl ([dst register?] [i (integer-in 0 63 )])]{
1730+ Alias for @racket[Sal].
1731+ }
1732+
1733+ @defstruct*[Shr ([dst register?] [i (integer-in 0 63 )])]{
1734+ Shift @racket[dst] to the right @racket[i] bits and put result in @racket[dst].
1735+ For each shift count, the least-significant (rightmost) bit is shifted into
1736+ the carry flag, and the most-significant bit is cleared. Updates the
1737+ conditional flags.
1738+
1739+ @#reader scribble/comment-reader
1740+ (ex
1741+ (asm-interp
1742+ (prog
1743+ (Global 'entry )
1744+ (Label 'entry )
1745+ (Mov 'rax #b100000000 ) ; #b100000000 = 256
1746+ (Shr 'rax 6 )
1747+ (Ret))) ; #b100 = 4
1748+
1749+ (asm-interp
1750+ (prog
1751+ (Global 'entry )
1752+ (Label 'entry )
1753+ (Mov 'rax #b100001101 ) ; #b100001101 = 269
1754+ (Shr 'rax 6 )
1755+ (Ret))) ; #b100 = 4
1756+
1757+ (asm-interp
1758+ (prog
1759+ (Global 'entry )
1760+ (Label 'entry )
1761+ (Mov 'rax #b1000000000000000000000000000000000000000000000000000000000000000 ) ; 1 in MSB
1762+ (Shr 'rax 6 )
1763+ (Ret))) ; #b0000001000000000000000000000000000000000000000000000000000000000
17161764 )
17171765}
17181766
0 commit comments