Skip to content

Commit cba7efe

Browse files
committed
A note on Cmov in notes.
1 parent cfbb32c commit cba7efe

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

www/notes/dupe.scrbl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,11 +847,21 @@ just how @racket[interp-bits] interprets an @racket[add1].}
847847
@item{@racket[(sub1 _e)]: should work like @racket[(add1 _e)] but
848848
subtracting @racket[#,(value->bits 1)].}
849849

850-
@item{@racket[(zero? _e)]: this should produce the
850+
@item{@racket[(zero? _e)]: this should produce the
851851
instructions for @racket[_e] followed by instructions that
852852
compare @racket['rax] to 0 and set @racket['rax] to
853853
@racket[#t] (i.e. @binary[val-true 2]) if true and
854-
@racket[#f] (i.e. @binary[val-false 2]) otherwise.}
854+
@racket[#f] (i.e. @binary[val-false 2]) otherwise.
855+
856+
This is a bit different from what we saw with Con, which combined
857+
conditional execution with testing for equality to @racket[0]. Here
858+
there is no need to @emph{jump} anywhere based on whether @racket[_e]
859+
produces @racket[0] or not. Instead we want to move either the
860+
encoding of @racket[#t] or @racket[#f] into @racket['rax] depending on
861+
what @racket[_e] produces. To accomplish that, we can use a new kind
862+
of instruction, the @bold{conditional move} instruction: @racket[Cmov].
863+
864+
}
855865

856866
@item{@racket[(if _e0 _e1 _e2)]: this should work much like before,
857867
compiling each subexpression, generating some labels and the

0 commit comments

Comments
 (0)