Skip to content

Commit 422b15d

Browse files
committed
Sketch of jig notes.
1 parent 9082460 commit 422b15d

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

www/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $(course):
1717
$(course).scrbl
1818
mkdir -p $(course)/code/
1919
cd notes ; \
20-
tar -c `git ls-files -X .gitignore intro abscond blackmail con dupe extort fraud hustle` | \
20+
tar -c `git ls-files -X .gitignore intro abscond blackmail con dupe extort fraud hustle iniquity` | \
2121
(cd ../main/code ; tar -x) ; cd ../..
2222

2323
clean:

www/notes.scrbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@include-section{notes/grift.scrbl}
1616
@include-section{notes/hustle.scrbl}
1717
@include-section{notes/iniquity.scrbl}
18+
@include-section{notes/jig.scrbl}
1819
@;{
1920
@include-section{notes/5.scrbl}
2021
@include-section{notes/6.scrbl}

www/notes/jig/asm/printer.rkt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
[`(neg ,a1)
3232
(string-append "\tneg " (arg->string a1) "\n")]
3333
[`(call ,l)
34-
(string-append "\tcall " (arg->string l) "\n")]
34+
(string-append "\tcall " (label->string l) "\n")]
3535
[`(push ,r)
36-
(string-append "\tpush " (reg->string r) "\n")]
36+
(string-append "\tpush " (reg->string r) "\n")]
37+
[`(pop ,r)
38+
(string-append "\tpop " (reg->string r) "\n")]
3739
[l (string-append (label->string l) ":\n")]))
3840

3941
(define (opcode2? x)
@@ -53,7 +55,7 @@
5355
;; Any -> Boolean
5456
(define (reg? x)
5557
(and (symbol? x)
56-
(memq x '(rax rbx rcx rsp rdi rip))))
58+
(memq x '(rax rbx rcx rdx rsp rdi rip rbp rsi r8 r9 r10 r11 r12 r13 r14 r15))))
5759

5860
;; Reg -> String
5961
(define (reg->string r)
@@ -74,6 +76,7 @@
7476
(display
7577
(string-append "\tglobal " (label->string g) "\n"
7678
"\tdefault rel\n"
77-
"\textern " (label->string 'error) "\n"
79+
"\textern " (label->string 'error) "\n"
80+
"\textern " (label->string 'plus_two) "\n"
7881
"\tsection .text\n"
7982
(asm->string a)))))

www/notes/jig/compile.rkt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
(define imm-type-bool (arithmetic-shift #b01 result-shift))
1919
(define imm-type-char (arithmetic-shift #b10 result-shift))
2020
(define imm-type-empty (arithmetic-shift #b11 result-shift))
21-
22-
23-
2421
(define imm-val-false imm-type-bool)
25-
(define imm-val-true (bitwise-ior (arithmetic-shift 1 (add1 imm-shift)) imm-type-bool))
22+
(define imm-val-true
23+
(bitwise-ior (arithmetic-shift 1 (add1 imm-shift)) imm-type-bool))
2624

2725
;; Allocate in 64-bit (8-byte) increments, so pointers
2826
;; end in #b000 and we tag with #b001 for boxes, etc.
@@ -51,12 +49,10 @@
5149
`(entry
5250
,@(compile-tail-e e '())
5351
ret
54-
5552
err
5653
(push rbp)
57-
(call error)
58-
ret))
59-
54+
(call error)))
55+
6056
;; Expr CEnv -> Asm
6157
;; Compile an expression in tail position
6258
(define (compile-tail-e e c)

0 commit comments

Comments
 (0)