Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion www/assignments/3.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ Implement the @racket[cond] expression form as described earlier.
To do this, you should:

@itemlist[
@item{Study @tt{ast.rkt} to add appropriate AST nodes.}
@item{Study @tt{ast.rkt} to understand how these new forms of
expression are represented.}

@item{Update @tt{interp-prim.rkt} and @tt{interp.rkt} to correctly interpret @racket[cond] expressions.}

@item{Make examples of @racket[cond]-expressions and potential translations of them
Expand Down
4 changes: 2 additions & 2 deletions www/notes/abscond.scrbl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#lang scribble/manual

@(require (for-label (except-in racket compile) a86/ast a86/printer))
@(require (for-label (except-in racket compile) a86/ast a86/printer a86/registers))
@(require scribble/examples
redex/reduction-semantics
redex/pict
Expand Down Expand Up @@ -429,7 +429,7 @@ So the AST representation of our example is:

@racketblock[
(list (Label 'entry)
(Mov 'rax 42)
(Mov rax 42)
(Ret))
]

Expand Down
12 changes: 6 additions & 6 deletions www/notes/blackmail.scrbl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#lang scribble/manual

@(require (for-label (except-in racket compile ...) a86/ast a86/printer))
@(require (for-label (except-in racket compile ...) a86/ast a86/printer a86/registers a86/interp))
@(require scribble/examples
redex/pict
"../fancyverb.rkt"
Expand Down Expand Up @@ -238,7 +238,7 @@ Just as we did with Abscond, let's approach writing the compiler by
first writing an example.

Suppose we want to compile @racket[(add1 (add1 40))]. We already know
how to compile the @racket[40]: @racket[(Mov 'rax 40)]. To do the
how to compile the @racket[40]: @racket[(Mov rax 40)]. To do the
increment (and decrement) we need to know a bit more a86. In
particular, the @racket[Add] instruction is relevant. It increments
the contents of a register by some given amount.
Expand All @@ -250,9 +250,9 @@ So, a program that adds 1 twice to 40 looks like:
(asm-interp
(prog (Global 'entry)
(Label 'entry)
(Mov 'rax 40)
(Add 'rax 1)
(Add 'rax 1)
(Mov rax 40)
(Add rax 1)
(Add rax 1)
(Ret)))]


Expand All @@ -275,7 +275,7 @@ recursion, much like the interpreter.
In the case of a unary primitive @racket[(Prim1 p e)], the compiler
first compiles the subexpression @racket[e] obtaining a list of
instructions that, when executed, will place @racket[e]'s value in the
@racket['rax] register. After that sequence of instructions, the
@racket[rax] register. After that sequence of instructions, the
compiler emits instructions for carrying out the operation @racket[p],
defering to a helper function @racket[compile-op1]:

Expand Down
16 changes: 8 additions & 8 deletions www/notes/con.scrbl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#lang scribble/manual

@(require (for-label (except-in racket compile ...) a86/printer a86/ast))
@(require (for-label (except-in racket compile ...) a86/printer a86/ast a86/registers))
@(require redex/pict
racket/runtime-path
scribble/examples
Expand Down Expand Up @@ -191,8 +191,8 @@ We already know how to compile the @racket[8], @racket[2], and
What needs to happen?

@itemlist[
@item{Execute the code for @racket[8] leaving the result in @racket['rax],}
@item{check whether @racket['rax] holds zero,}
@item{Execute the code for @racket[8] leaving the result in @racket[rax],}
@item{check whether @racket[rax] holds zero,}
@item{if it does, execute the code for @racket[2],}
@item{if it doesn't, execute the code for @racket[3].}
]
Expand All @@ -219,10 +219,10 @@ In total, the code for this example would look like:
@racketblock[
(let ((l0 (gensym))
(l1 (gensym)))
(list (Mov 'rax 8)
(Cmp 'rax 0)
(list (Mov rax 8)
(Cmp rax 0)
(Je l0)
(Mov 'rax 3)
(Mov rax 3)
(Jmp l1)
(Label l0)
(Mov rax 2)
Expand All @@ -232,7 +232,7 @@ In total, the code for this example would look like:

@section{A Compiler for Con}

Notice that the @racket[(Mov 'rax 8)], @racket[(Mov rax 3)] and
Notice that the @racket[(Mov rax 8)], @racket[(Mov rax 3)] and
@racket[(Mov rax 2)] parts are just the instructions generated by
compiling @racket[8], @racket[2] and @racket[3]. Generalizing from
this, we arrive at the following code for the compiler:
Expand All @@ -241,7 +241,7 @@ this, we arrive at the following code for the compiler:
(let ((l0 (gensym 'if))
(l1 (gensym 'if)))
(seq (compile-e e1)
(Cmp 'rax 0)
(Cmp rax 0)
(Je l0)
(compile-e e3)
(Jmp l1)
Expand Down
16 changes: 8 additions & 8 deletions www/notes/dupe.scrbl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#lang scribble/manual

@(require (for-label (except-in racket ... compile) a86/printer a86/ast))
@(require (for-label (except-in racket ... compile) a86/printer a86/ast a86/registers a86/interp))
@(require redex/pict
racket/runtime-path
scribble/examples
Expand Down Expand Up @@ -271,14 +271,14 @@ To make the problem concrete, consider the Dupe expression
that moves this value into the @racket[rax] register:

@ex[
(Mov 'rax 5)]
(Mov rax 5)]

But now consider @racket[#t]. The compiler needs to emit an
instruction that moves ``@racket[#t]'' into @racket[rax], but the
@racket[Mov] instruction doesn't take booleans:

@ex[
(eval:error (Mov 'rax #t))]
(eval:error (Mov rax #t))]

We have to move some 64-bit integer into @racket[rax], but the
question is: which one?
Expand All @@ -289,12 +289,12 @@ C tradition and say @racket[#f] will be @racket[0] and @racket[#t]
will be 1. So compiling @racket[#t] would emit:

@ex[
(Mov 'rax 1)]
(Mov rax 1)]

And compiling @racket[#f] would emit:

@ex[
(Mov 'rax 0)]
(Mov rax 0)]

Seems reasonable. Well except that the specification of @racket[if]
in our interpreter requires that @racket[(if 0 1 2)] evaluates to
Expand Down Expand Up @@ -925,12 +925,12 @@ Let's consider some simple examples:

@item{@racket[42]: this should compile just like integer literals
before, but needs to use the new representation, i.e. the compiler
should produce @racket[(Mov 'rax #,(value->bits 42))], which is
should produce @racket[(Mov rax #,(value->bits 42))], which is
@racket[42] shifted to the left @racket[#,int-shift]-bit.}

@item{@racket[#f]: this should produce @racket[(Mov 'rax #,(value->bits #f))].}
@item{@racket[#f]: this should produce @racket[(Mov rax #,(value->bits #f))].}

@item{@racket[#t]: this should produce @racket[(Mov 'rax #,(value->bits #t))].}
@item{@racket[#t]: this should produce @racket[(Mov rax #,(value->bits #t))].}

@item{@racket[(add1 _e)]: this should produce the instructions for
@racket[_e], which when executed would leave @emph{the encoding of the
Expand Down