Skip to content

Commit 1827584

Browse files
authored
Merge pull request #198 from cmsc430/fall-2025
Fall 2025
2 parents 20de3e3 + a6e3c20 commit 1827584

File tree

5 files changed

+27
-25
lines changed

5 files changed

+27
-25
lines changed

www/assignments/3.scrbl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ Implement the @racket[cond] expression form as described earlier.
140140
To do this, you should:
141141

142142
@itemlist[
143-
@item{Study @tt{ast.rkt} to add appropriate AST nodes.}
143+
@item{Study @tt{ast.rkt} to understand how these new forms of
144+
expression are represented.}
145+
144146
@item{Update @tt{interp-prim.rkt} and @tt{interp.rkt} to correctly interpret @racket[cond] expressions.}
145147

146148
@item{Make examples of @racket[cond]-expressions and potential translations of them

www/notes/abscond.scrbl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#lang scribble/manual
22

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

430430
@racketblock[
431431
(list (Label 'entry)
432-
(Mov 'rax 42)
432+
(Mov rax 42)
433433
(Ret))
434434
]
435435

www/notes/blackmail.scrbl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#lang scribble/manual
22

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

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

258258

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

www/notes/con.scrbl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#lang scribble/manual
22

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

193193
@itemlist[
194-
@item{Execute the code for @racket[8] leaving the result in @racket['rax],}
195-
@item{check whether @racket['rax] holds zero,}
194+
@item{Execute the code for @racket[8] leaving the result in @racket[rax],}
195+
@item{check whether @racket[rax] holds zero,}
196196
@item{if it does, execute the code for @racket[2],}
197197
@item{if it doesn't, execute the code for @racket[3].}
198198
]
@@ -219,10 +219,10 @@ In total, the code for this example would look like:
219219
@racketblock[
220220
(let ((l0 (gensym))
221221
(l1 (gensym)))
222-
(list (Mov 'rax 8)
223-
(Cmp 'rax 0)
222+
(list (Mov rax 8)
223+
(Cmp rax 0)
224224
(Je l0)
225-
(Mov 'rax 3)
225+
(Mov rax 3)
226226
(Jmp l1)
227227
(Label l0)
228228
(Mov rax 2)
@@ -232,7 +232,7 @@ In total, the code for this example would look like:
232232

233233
@section{A Compiler for Con}
234234

235-
Notice that the @racket[(Mov 'rax 8)], @racket[(Mov rax 3)] and
235+
Notice that the @racket[(Mov rax 8)], @racket[(Mov rax 3)] and
236236
@racket[(Mov rax 2)] parts are just the instructions generated by
237237
compiling @racket[8], @racket[2] and @racket[3]. Generalizing from
238238
this, we arrive at the following code for the compiler:
@@ -241,7 +241,7 @@ this, we arrive at the following code for the compiler:
241241
(let ((l0 (gensym 'if))
242242
(l1 (gensym 'if)))
243243
(seq (compile-e e1)
244-
(Cmp 'rax 0)
244+
(Cmp rax 0)
245245
(Je l0)
246246
(compile-e e3)
247247
(Jmp l1)

www/notes/dupe.scrbl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#lang scribble/manual
22

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

273273
@ex[
274-
(Mov 'rax 5)]
274+
(Mov rax 5)]
275275

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

280280
@ex[
281-
(eval:error (Mov 'rax #t))]
281+
(eval:error (Mov rax #t))]
282282

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

291291
@ex[
292-
(Mov 'rax 1)]
292+
(Mov rax 1)]
293293

294294
And compiling @racket[#f] would emit:
295295

296296
@ex[
297-
(Mov 'rax 0)]
297+
(Mov rax 0)]
298298

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

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

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

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

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

0 commit comments

Comments
 (0)